In my graduation project, I put all the jsp pages in the WEB-INF folder. However, a problem occurs. WEB-INF is a protected folder, and we cannot access the resources in it through the regular method, that is, if we write the following code in frameset, it cannot be accessed:
1 <frame src="/WEB-INF/page/admin_righr.jsp" name="main" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"/>
The above code reports a 404 error.
So how can we solve this problem? There are three solutions:
I. Use Struts Framework
1. When src is configured in the frame, point it to an action.
1 <frame src="${pageContext.request.contextPath }/adminIndex/toAdmin_toAdminRight.action" name="main" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"/>
2. Return a string in the processing method. Then point to the jsp file to be loaded when processing results in struts. xml.
1 /**2 * admin_right.jsp3 */4 public String toAdminRight(){5 return "adminRight";6 }
1 <package name="adminIndex" namespace="/adminIndex" extends="struts-default">2 <action name="toAdmin_*" class="adminIndexAction" method="{1}">3 <result name="adminRight">/WEB-INF/page/backstage/admin_right.jsp</result>4 </action>5 </package>
Ii. Use Servlet
1 <servlet>2 <servlet-name>servletName</servlet-name>3 <jsp-file>/WEB-INF/admin_right.jsp>4 </servlet>5 <servlet-mapping>6 <servlet-name>servletName</servlet-name>7 <url-pattern>/.do</url-pattern>8 <servlet-mapping>
Then you can point to the servlet.
3. Use <jsp: forward page = "WEB-INF/XXX"> to directly access the jsp under the web-inf directory.