-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeHtmlPage.java
More file actions
35 lines (28 loc) · 912 Bytes
/
HomeHtmlPage.java
File metadata and controls
35 lines (28 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package server;
import java.io.UnsupportedEncodingException;
public class HomeHtmlPage extends HtmlPage {
private StringBuilder content;
public HomeHtmlPage() {
content = new StringBuilder();
super.generateFrame(content);
String buttons = "<div style='margin:50px'>"
+ "<a href='/index?ver=new' type='button' class='btn btn-info btn-block'>新购物单</a></div>"
+ "<div style='margin:50px'>"
+ "<a href='/index?ver=old' type='button' class='btn btn-info btn-block'>查看上次购物单</a></div>";
content.insert(content.indexOf("</body>"), buttons);
}
@Override
protected int getContentLength() {
try {
return this.content.toString().getBytes("utf-8").length;
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
@Override
protected String getContent() {
return this.content.toString();
}
}