The path problem in struts2 is determined based on the path of Action rather than the path of JSP, so try not to use relative paths. Using relative paths will make the path problem very cumbersome and troublesome. Sometimes a subtle change will cause you to make major changes.
The solution is actually very simple: that is, use absolute paths uniformly.
In jsp, you can obtain the absolute path of the webapp by request.getContextRoot:
Copy the code as follows: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
The above method is very clear. The path string is obtained as the path to the webapp, and then the basePath is obtained as the root path of the entire project (Note: the last "/" already contains)
When using it, just call basePath (to jump to index as an explanation):
Copy the code as follows: <a href="<%=basePath %>index.jsp">index.jsp</a>
Where <a></a> represents a hyperlink, so you can jump to xxxxx/index (provided that your namespace and Action settings must be configured properly).
The above is the entire content of the path problem in Struts2. I hope you can give you a reference and I hope you can support Wulin.com more.