課程
/后端開發
/Java
/JAVA遇見HTML——JSP篇
真實路徑是null對嗎?
2014-09-25
源自:JAVA遇見HTML——JSP篇 3-8
正在回答
怎么解決呢,也遇到這個問題了
我也是出現同樣的問題,看到有一個警告提示是說:The method getRealPath(String) from the type ServletRequest is deprecated
應該是:tomcat安裝路徑\webapps\項目名字\request.jsp 才對。
gary_gary
<%@?page?language="java"?import="java.util.*"?contentType="text/html;?charset=UTF-8"?%> <% String?path?=?request.getContextPath(); String?basePath?=?request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"> <html> ??<head> ????<base?href="<%=basePath%>"> ???? ????<title>request內置對象</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"> <!-- <link?rel="stylesheet"?type="text/css"?href="styles.css"> --> ??</head> ?? ??<body> ???<h1>request內置對像</h1> ??<% ????request.setCharacterEncoding("utf-8");?//解決中文亂碼問題,無法解決URl傳參的亂碼問題 ????request.setAttribute("password",?"123456"); ???%> ??用戶名:<%=request.getParameter("username")?%><br> ??愛好:<% ??if(request.getParameterValues("favorite")!=null) ??{ ?????String[]?favorites?=?request.getParameterValues("favorite"); ?????for(int?i=0;i<favorites.length;i++) ?????{ ???????out.println(favorites[i]+" "); ?????} ???} ???%><br> ??????密碼:<%=request.getAttribute("password")%><br> ??????請求的MIME類型:<%=request.getContentType()?%><br> ??????獲得協議類型及版本號:<%=request.getProtocol()?%><br> ??????獲得服務器主機名字:<%=request.getServerName()?%><br> ??????獲得服務器的端口號:<%=request.getServerPort()?%><br>??? ??????請求文件的長度:<%=request.getContentLength()?%><br> ??????請求客戶端的IP地址:<%=request.getRemoteAddr()?%><br> ??????請求的真實物理路徑:<%=request.getRealPath("request.jsp")?%><br> ?????請求的上下文路徑:<%=request.getContextPath()?%>?<br> ??</body> </html>
親,能不能把你jsp里面的代碼粘貼出來,好幫你分析原因。
舉報
Java Web入門級教程JSP,帶你輕松的學習JSP基礎知識
4 回答sesstion.setMaxInactiveInterval(10); 為什么回報錯?
1 回答什么是request對象
2 回答有點區分不清cookie和session的作用?
1 回答response對象
2 回答請求重定向和請求轉發的區別
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-07-10
怎么解決呢,也遇到這個問題了
2015-05-01
我也是出現同樣的問題,看到有一個警告提示是說:The method getRealPath(String) from the type ServletRequest is deprecated
2014-10-08
應該是:tomcat安裝路徑\webapps\項目名字\request.jsp 才對。
2014-09-29
2014-09-26
親,能不能把你jsp里面的代碼粘貼出來,好幫你分析原因。