導航:首頁 > 編程語言 > 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對象相關的資料

熱點內容
半條命2有幾個版本 瀏覽:333
電腦管家微信備份文件夾 瀏覽:826
ubuntu文件夾解鎖 瀏覽:34
網站多少錢一單 瀏覽:382
系統鏡像恢復找不到文件 瀏覽:255
進什麼網站 瀏覽:588
修改了配置文件代碼沒有讀出來 瀏覽:749
vss資料庫是什麼 瀏覽:899
奇跡13單機系統找不到指定文件 瀏覽:719
flyme魅藍3以前的版本 瀏覽:318
安卓文件管理哪些文件夾可以刪除 瀏覽:290
安卓車載導航沒有聲音是怎麼回事 瀏覽:810
cjson數組格式 瀏覽:159
vb文件在哪裡 瀏覽:215
工廠里都招什麼編程人員 瀏覽:932
jspsql登錄 瀏覽:981
網路用語粉絲閱讀什麼意思 瀏覽:333
紅頭文件怎麼列印 瀏覽:94
熱血江湖130刺客升級 瀏覽:106
jsp頁面放大鏡技術介紹 瀏覽:101

友情鏈接