为什么Spring的ModelAndView对象没有设置viewname?

为什么Spring的ModelAndView对象没有设置viewname?,spring,jsp,controller,Spring,Jsp,Controller,我的jsp页面代码: <li><a href="viewAllProducts.htm"><i class="fa fa-angle-double-right"></i>View All Products</a></li> 当此操作被称为sout时,将在apache tomcat输出窗口中打印,但页面将在ModelAndView对象中设置。。 有人能提供解决方案吗 浏览器显示以下错误: HTTP Status 404 -

我的jsp页面代码:

<li><a href="viewAllProducts.htm"><i class="fa fa-angle-double-right"></i>View All Products</a></li>
当此操作被称为sout时,将在apache tomcat输出窗口中打印,但页面将在ModelAndView对象中设置。。 有人能提供解决方案吗

浏览器显示以下错误:

HTTP Status 404 - /AntixxWeb/WEB-INF/jsp/viewAllProducts.jsp

type Status report

message /AntixxWeb/WEB-INF/jsp/viewAllProducts.jsp

description The requested resource is not available.

Apache Tomcat/8.0.3

检查您正在访问的相应页面的URL。 您似乎在application-context.xml/-servlet.xml中错误配置了project的资源

您可以使用以下配置

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

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

</beans>

据我所知,URL应该是http://localhost:8080/project_name/viewAllProducts.htm.

如果要返回模型视图对象,请将其替换为所需的页面名称
在该页面中,您可以获取fetch model view object object

您可以展示如何在XML中配置viewResolver吗您如何尝试访问控制器?这是我的dispatcher-servlet.xml。我的操作名称是viewAllProducts.htm,页面名称是ViewAllProductsPage
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

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

</beans>