Through the browser's developer tools to view the Web page source code found that the path of resources such as css,js,img error, the path to the front of a more than one controller path, similar to:
http://localhost:8080/Project root/Controller name/js/jquery-1.9.1.min.js
Workaround: In the JSP page, set the path of the resource to ... /js/jquery-1.9.1.min.js This will return the controller's previous path, and the resulting path is:
http://localhost:8080/Project root directory/js/jquery-1.9.1.min.js
Above this solution is not good, assuming that there is a scenario: I started the project in MyEclipse, the first run is a landing page, the path is
http://localhost:8080/Project root directory/login.jsp
Login.jsp inside the css,js,img and other resources such as the relative path such as./js/jquery-1.9.1.min.js.
After I login, login successfully entered a new page, in this new page has an exit Login button, this button click to jump to the controller, the path of this controller is:
http://localhost:8080/Project root/Controller name/controller inside method name
In this controller inside I do some exit login operation, after these operations, I jump to the login.jsp page again, this time login.jsp inside css,js,img and other resources of the path to change again to
http://localhost:8080/Project root/Controller name/js/jquery-1.9.1.min.js
Still can't load resources, so the final solution is: referencing Css,js,img and other resource files, and in the JSP page to jump to other pages or controllers when using absolute path.
Add this code to the header of the JSP page:
<%
String Path = Request.getcontextpath ();
String basepath = request.getscheme () + "://"
+ request.getservername () + ":" + request.getserverport ()
+ path + " /";
%>
Change the relative path of resource files such as css,js,img and access controllers to absolute paths:
./js/jquery-1.9.1.min.js => <%=basepath%>js/jquery-1.9.1.min.js