This question already has answers here:
JSP in /WEB-INF returns “HTTP Status 404 The requested resource is not available”
                                
                                    (3个答案)
                                
                        
                                3年前关闭。
            
                    
1。

如果在cmd中运行startup.bat
在网路上看不到

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


可以在网上看到

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


2。
而且,如果经过日食,则比上述情况更糟,无法在index.html中看到http://localhost:8080/
这是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>

最佳答案

自动保护WEB-INF和META-INF文件夹中的页面不受外部访问。
只需将要提供的页面移出两个文件夹,您应该已经可以看到您的页面了。

07-24 15:12