Home > Article > Web Front-end > Detailed explanation of how to directly access JSP pages in the WEB-INF directory
This article mainly introduces relevant information on how to directly access the JSP page in the WEB-INF directory. Friends who are interested in JSP can refer to the detailed explanation below to access directly. Methods for the JSP page in the WEB-INF directory
The JSP page in the WEB-INF directory cannot be directly accessed through the address bar, and the files in the WEB-INF directory cannot be directly accessed. Access is mainly for security reasons. Of course, if security is not a concern, you can directly put the JSP page in the webapp directory outside WEB-INF, so that you can also access it directly. Let’s talk about how to directly access the jsp page in the WEB-INF directory
It can be accessed through forwarding. I use Controller for forwarding, as follows:
package com.sogou.baike.controller; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; /** * Created by denglinjie on 2016/6/3. */ @Controller public class CompareController { private static Logger logger = Logger.getLogger(CompareController.class); @RequestMapping(value = "/api/compare", produces = "text/html; charset=utf-8") public ModelAndView getCompareHomePage() { ModelAndView view = new ModelAndView("compare"); return view; } }
In this way, when the page is requested, you can enter
http://10.10.10.10:30005/api/compare
## in the address bar.
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/vm/" /> <property name="suffix" value=".jsp" /> </bean>
How to redirect a web page in jsp
How to test a JSP page outside the container
JSP basic knowledge points summary
The above is the detailed content of Detailed explanation of how to directly access JSP pages in the WEB-INF directory. For more information, please follow other related articles on the PHP Chinese website!