无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

第二次操作考試:Java web字符串拼接,顯示成表格,有時(shí)要記憶,默寫內(nèi)容【詩(shī)書畫唱】

2020-10-06 21:54 作者:詩(shī)書畫唱  | 我要投稿



package T;


public class Product {

? ? private String name;

? ? private Double price;

? ? public Product(String n,Double p) {

// TODO Auto-generated constructor stub

? ? this.name = n;

? ? this.price = p;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public Double getPrice() {

return price;

}

public void setPrice(Double price) {

this.price = price;

}

}

package T;


import java.io.IOException;

import java.util.ArrayList;

import java.util.List;


import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


/**

?* Servlet implementation class TestServlet

?*/

@WebServlet("/ts")

public class TestServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

? ? ? ?

? ? /**

? ? ?* @see HttpServlet#HttpServlet()

? ? ?*/

? ? public TestServlet() {

? ? ? ? super();

? ? ? ? // TODO Auto-generated constructor stub

? ? }


/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

*/

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

this.doPost(request, response);

}


/**

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)

*/

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

List<Product>list = new ArrayList<Product>();

for(int i = 0;i < 3;i ++) {

Product p = new Product("商品" + i,3.3 + i);

list.add(p);

}

//將List中的數(shù)據(jù)拼接成一個(gè)表格,并且顯示出來(lái)

StringBuilder html = new StringBuilder();

html.append("<table border='1'><tr><th>商品名稱"

+ "</th><th>商品價(jià)格</th><th>操作</th></tr>");

for(Product p : list) {

html.append("<tr><td>");

html.append(p.getName());

html.append("</td><td>");

html.append(p.getPrice());

html.append("</td><td><a href='#'>修改</a></td></tr>");

}

html.append("</table>");

// System.out.println(html);

response.setCharacterEncoding("gbk");

//將html代碼顯示在頁(yè)面上

response.getWriter().write(html.toString());

}


}



第二次操作考試:Java web字符串拼接,顯示成表格,有時(shí)要記憶,默寫內(nèi)容【詩(shī)書畫唱】的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
黄陵县| 体育| 吉首市| 大丰市| 盐城市| 南溪县| 西乡县| 东港市| 西城区| 德保县| 绥芬河市| 宁晋县| 宣汉县| 焦作市| 古交市| 山西省| 杨浦区| 江口县| 衡阳市| 贵德县| 徐州市| 成武县| 延安市| 黄龙县| 兴文县| 辰溪县| 麻栗坡县| 景德镇市| 江口县| 方城县| 射洪县| 新巴尔虎左旗| 汨罗市| 茂名市| 大渡口区| 商水县| 安阳县| 鄱阳县| 朝阳市| 襄垣县| 睢宁县|