hzuapps / java-web Goto Github PK
View Code? Open in Web Editor NEW高级网页设计(Java Web)实验库
高级网页设计(Java Web)实验库
实验要求:
参考资料:
http://blog.csdn.net/justjackwang/article/details/8804528
1.创建手机订单
2.录入售后信息
客户叫车,车主找客户。
1.购票
2.退票
1.客户提交订单;
2.客户修改订单;
Class.forName("");
注意:驱动程序应该到对应的数据库厂商网站下载,如:PostgreSQL https://jdbc.postgresql.org/download.html 。
Tips:准备面试还应该了解JDBC驱动的4种类型。
String url = "jdbc:postgresql://<database_host>:<port>/<database_name>";
Connection con = DriverManager.getConnection(url, "userID", "password");
好的做法是保存在常量中,例如:
private final String url = "jdbc:postgresql://localhost/dvdrental";
private final String user = "postgres";
private final String password = "<add your password>";
详细的连接代码:
public Connection connect() {
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
System.out.println("Connected to the PostgreSQL server successfully.");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return conn;
}
更好的做法是将配置保存在配置文件中,如:jdbc.properties,可方便数据库连接管理,如切换开发与生产数据库。Hibernate等框架也采用这种方法。(问:Hibernate是怎么配置的?)
select * from TABLE_NAME;
insert into ... ;
update ...;
delete ...;
http://www.w3school.com.cn/sql/
public int getActorCount() {
String SQL = "SELECT count(*) FROM actor";
int count = 0;
try (Connection conn = connect();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(SQL)) {
rs.next();
count = rs.getInt(1);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
return count;
}
public long insertActor(Actor actor) {
String SQL = "INSERT INTO actor(first_name,last_name) "
+ "VALUES(?,?)";
long id = 0;
try (Connection conn = connect();
PreparedStatement pstmt = conn.prepareStatement(SQL,
Statement.RETURN_GENERATED_KEYS)) {
pstmt.setString(1, actor.getFirstName());
pstmt.setString(2, actor.getLastName());
int affectedRows = pstmt.executeUpdate();
// check the affected rows
if (affectedRows > 0) {
// get the ID back
try (ResultSet rs = pstmt.getGeneratedKeys()) {
if (rs.next()) {
id = rs.getLong(1);
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
return id;
}
TODO
TODO
1.统计收入情况
2.统计支出情况
3.计算盈亏情况
练习并掌握简单HTML网页制作方法。
操作系统:Windows;开发平台:GitHub;开发工具:Sublime Text。
$ git pull
$ git add labs/{你的学号}/*
$ git commit -m "#2 提交实验代码"
$ git push
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" id="exampleInputFile">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
$( "#target" ).submit(function( event ) {
alert( "Handler for .submit() called." );
event.preventDefault();
});
$.ajax({
url: "success.json
}).done(function(data) {
if ( console && console.log ) {
console.dir(data);
alert(data.msg);
}
});
{
"msg": "保存成功!"
}
任选一个框架练习,截图保存到实验报告提交。
参考文档:
Good morning!Hi,Mr.zeng,could you tell us your WeChat number?
练习使用过滤器实现请求批量处理。
http://m.blog.csdn.net/article/details?id=5485742
Java代码放到自己的包下,采用注解的方式注入过滤器。
http://www.th7.cn/Program/java/2012/06/06/79329.shtml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.