开发者

HTTP 404 problem JSP can not see in web [duplicate]

This question already has answers here: 开发者_Go百科 JSP in /WEB-INF returns "HTTP Status 404 The requested resource is not available" (3 answers) Closed 6 years ago.

1.

if run startup.bat in cmd can not see in web

apache-tomcat-6.0.30\webapps\AbstractCommandDemo\WebContent\WEB-INF\index.html
apache-tomcat-6.0.30\webapps\AbstractCommandDemo\WebContent\WEB-INF\jsp\userInfo.jsp
localhost:8080/AbstractCommandDemo/userInfo.jsp
localhost:8080/AbstractCommandDemo/user.do
localhost:8080/AbstractCommandDemo/WEB-INF/jsp/userInfo.jsp

can see in web

apache-tomcat-6.0.30\webapps\AbstractCommandDemo\index.html

2. Moreover, if running through eclipse, worse than above situation, can not see index.html in http://localhost:8080/ which is apache-tomcat-6.0.30\webapps\AbstractCommandDemo\index.html

<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>AbstractCommandController Demo</title>
</head>
<body>
    <h1>name:${userInfo['name']}</h1>
    <h1>password:${userInfo['password']}</h1>
</body>
</html>

web.xml

<session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/mvcconfig.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcherServlet</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

mvcconfig.xml

 <bean id="urlMapping" 
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
        <property name="mappings"> 
            <props> 
                <prop key="/user.do">userController</prop> 
            </props> 
        </property> 
    </bean> 

    <bean id="viewResolver" 
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
        <property name="prefix" value="/WEB-INF/jsp/"/> 
        <property name="suffix" value=".jsp"/> 
    </bean> 

    <bean id="userController" 
          class="onlyfun.caterpillar.UserController"> 
        <property name="userPage" value="userInfo"/> 
    </bean> 


pages in WEB-INF and META-INF folders are automatically protected from external access. Just move the pages you want to serve out of the two folders and you should be able to see your pages already.


in the tomcat webserver WEB-INF And MATA-INF dir is protectd so no one can access file from out sides

so you can call your file only form the servlet

if you are using jsp in WEB-INF / Jsp folder then you can you have to write servlet that can call your jsp file this is very secure way

other wise it will give you 404 error

write servlet that call your jsp or redirect your jsp in WEB-INF / Jsp Folder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜