小编gou*_*uki的帖子

Spring 3.0 MVC mvc:view-controller标签

这是我的mvc-config.xml的片段:

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

<mvc:view-controller path="/index" view-name="welcome"/>    
<mvc:view-controller path="/static/login" view-name="/static/login"/>   
<mvc:view-controller path="/login" view-name="/static/login"/>
Run Code Online (Sandbox Code Playgroud)

我在/ WEB-INF/view /目录下有welcome.jsp,在/ WEB-INF/view/static /上有login.jsp.

这适用于'/ index'和'/ login'路径.但是当我从浏览器调用时,我得到了'/ static/login'的404响应.我期待'/ static/login /'和'/ login'的行为应该相同.

这可能有什么问题?

非常感谢任何帮助.

谢谢!

这是web.xml:

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
    </context-param>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <!-- Enables clean URLs with JSP views e.g. /welcome instead of /app/welcome -->
    <filter>
        <filter-name>UrlRewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>UrlRewriteFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Handles all …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

spring ×1

spring-mvc ×1