導航:首頁 > 編程語言 > jstlrequest對象

jstlrequest對象

發布時間:2024-06-26 00:43:15

java 怎麼設置request的head

步驟如下:
1、在web工程裡面創建一個Servlet類,繼承HttpServlet,重寫doPost,doGet方法,在doPost方法中調用doGet方法;
2、在doGet方法中把要設置到jsp頁面的值存到request中;
3、在doGet方法中添加轉發到jsp頁面的代碼
4、在jsp頁面中使用jstl標簽獲取存入的值。
事例代碼如下:
Servlet類:
public class DemoServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute("name", "nameValue");
request.getRequestDispatcher("/demo.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
jsp頁面:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Demo</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
${name }
</body>
</html>

其中,<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>表示導入jstl標簽庫,沒導入的話無法使用jstl標簽,使用jstl標簽可以減少很多代碼量,導入jstl標簽後就可以通過使用${}的方法來獲取值了。

⑵ JSTL怎麼獲取request裡面的對象值。。。。求解。。。

你${requestScope.i}取的是一個對象,你要顯示的是對象里的屬性,所以還得再點裡面的屬性
或是將對象賦值給struts的s:set再點屬性

⑶ jsp得到request作用域傳來的List對象,怎麼輸出呢

<tableid='tb'>
<tr>
<th>商品編來號</th>
<th>評價自時間</th>
<th>評價內容</th>
</tr>
<%
List<comment>list=(List)session.getAttribute("list");
for(inti=0;i<list.size();i++){
<!--用實體類遍歷list來動態添加tr-->
commentcom=list.get(i);


%>
<tr>
<td><%=com.getUid()%></td>
<td><%=com.getCreate_time()%></td>
<td><%=com.getContent()%></td>
</tr>
<%
}
%>
</table>

閱讀全文

與jstlrequest對象相關的資料

熱點內容
如何提高配套文件科學性 瀏覽:552
免費qq在線客服代碼 瀏覽:615
網路攝像機和麥克風的使用點不了 瀏覽:872
win10資源文件夾卡死 瀏覽:431
聯想筆記本如何添加網路連接 瀏覽:821
釘釘文件下載到微信用哪個瀏覽器 瀏覽:252
word怎麼刪掉第一頁 瀏覽:215
為什麼小米5不能升級系統 瀏覽:768
復古攝影教程 瀏覽:803
u盤里文件顯示文件夾空 瀏覽:574
如何編程年月日的進制 瀏覽:351
升級電腦硬體注意什麼 瀏覽:827
cnc銑床多主軸如何編程 瀏覽:640
怎麼下載網站所有圖片 瀏覽:967
遠程傳文件最快的軟體下載 瀏覽:425
怎麼弄電影網站 瀏覽:209
淘寶編程培訓班怎麼樣 瀏覽:732
公文系統物理文件 瀏覽:903
c語言編程變數冪怎麼寫 瀏覽:73
bat文件怎麼寫 瀏覽:117

友情鏈接