spring MVC无法显示视图页面(home.jsp)

时间:2015-05-19 02:43:41

标签: spring-mvc

链接localhost:8080/Project/时我遇到404错误 我不知道为什么它不能显示home.jsp 请帮帮我

消息:

10:20:44.872 [http-nio-8080-exec-2] DEBUG o.s.web.servlet.view.JstlView - Forwarding to resource [/jsp/home.jsp] in InternalResourceView 'home'
10:20:44.877 [http-nio-8080-exec-2] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
10:20:44.879 [http-nio-8080-exec-2] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Chain processed normally
10:20:44.879 [http-nio-8080-exec-2] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed

HomeController.java

package com.our.user.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {

    @RequestMapping("/")
    public String showHome() {
        return "home";
    }
}

弹簧servlet.xml中

   <context:component-scan base-package="com.our.user.controller">
    </context:component-scan>
    <mvc:annotation-driven></mvc:annotation-driven>


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


   <context:annotation-config/>                                              
   <bean class="com.our.user.loginOperation.loginOperationImp"/> 

安全context.xml中

<security:http use-expressions="true">
    <security:intercept-url pattern="/index" access="isAuthenticated()" />
    <security:intercept-url pattern="/" access="permitAll" />
    <security:intercept-url pattern="/login" access="permitAll" />
    <security:intercept-url pattern="/**" access="denyAll" />
    <security:form-login />
</security:http>

1 个答案:

答案 0 :(得分:0)

在web.xml文件中尝试以下配置:

<mvc:view-controller path="/" view-name="home"/>

将在没有任何自定义后备控制器的情况下重定向到home路径模式的/页面。

Read more...

或者在没有security-context.xml的情况下再次尝试它可行,然后问题在于安全配置。