struts2中路径是根据action的路径而定的,在当前路径下点一个没有任何处理的jsp链接,例如<a href="index.jsp" /> 则当前工程目录不变,直接 跳转过去。如从
http://localhost:8080/project/action/path.jsp 则action不变,直接跳转到http://localhost:8080/project/action/index.jsp,这样当action变化了,会影响路径显示。
因此一般jsp中会写到
<% String path= request.getContextPath() %>
<% String basePath = request.getScheme + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %>
可以<a href="<%=basePath%>index.jsp" />
也可以写个标签<base href="<%=basePath%>"/> 这样,文件下的所有链接都不用加路径了。