JAVA WEB 中不不使用request response 对象 怎么能得到WEB的路径
只要能得到前面的就行了 比如 http://localhost:8080/gir 我要得到前面的 加上 工程名字 能动态得到就好了 拼字符串的方法也行
[解决办法]
你是想在javaBean當中獲得路徑吧。其實很簡單啊,建一個帶request參數的函數,JSP頁面上調用這個函數不就可以 使用request了嗎
[解决办法]
String root=getServletContext().getRealPath( "/ ");
[解决办法]
<%
String path = request.getContextPath();
String basePath = request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>
[解决办法]
String root=getServletContext().getRealPath( "/ ");
[解决办法]
以上的代码都实现么?
[解决办法]
上面方法好像都是要用的web环境的,而不是在一个普通javaBean中吧~