Struts2 path 路径问题说明
2017-06-22 22:25
465 查看
index.jsp<%--String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";//在head中<base href>指定basePath--%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=GB18030" /><title>Insert title here</title></head><body><a href="path/path.action">路径问题说明</a></body></html>path.jspString path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<base href="<%=basePath%>" /><title>Insert title here</title></head><body>struts2中的路径问题是根据action的路径而不是jsp路径来确定,所以尽量不要使用相对路径。<br /><a href="index.jsp">index.jsp</a><br />虽然可以用redirect方式解决,但redirect方式并非必要。<br />解决办法非常简单,统一使用绝对路径。(在jsp中用request.getContextRoot方式来拿到webapp的路径)<br />或者使用myeclipse经常用的,指定basePath</body></html>
相关文章推荐
- Struts2中的path路径问题、动态方法调用、通配符
- struts2 Path 路径问题
- Struts2 学习 第4part path(路径问题)
- Struts2关于Action的系统训练3关于Action创建和path路径问题
- 道听途说Struts2之4:Path路径问题
- struts视频12_尚学堂马士兵_Struts2_Struts2_Path_绝对路径问题
- Struts2_4_ Path路径问题
- struts2中action的路径问题以及在MyEclipse8.5中的说明(通配符等等)
- 【Struts2复习知识点四】-Path路径问题
- 【Struts2复习知识点四】-Path路径问题(转载)
- IE8上传文件时javascript取文件的本地路径的问题C:/fakepath/
- FileUpLoad选择图片后,直接将图片显示在image中。及IE8本地路径("C:/fakepath/")出现问题的解决方案
- IE8上传文件时javascript读取文件的本地路径的问题("C:/fakepath/")的解决方案
- 配置android时出现path问题,因为路径有中文,完美解决方法
- Struts2中namespace引发的路径问题
- .net中创建目录的问题(未找到路径X的一部分|Could not find a part of the path)
- IE8+上传文件时javascript取文件的本地路径的问题C:/fakepath/
- Java里面的路径问题,CLASSPATH和SOURCEPATH
- 说一下Java里面的路径问题,CLASSPATH和SOURCEPATH
- 获取上当前访问路径问题 (struts2)