2012-10-18 3 views
1

안녕하세요 저는 Spring을 처음 사용하고 JSP 매핑을 고수했습니다. 내 페이지는 404 - 페이지를 찾을 수 없음 오류를 제공합니다.Spring MVC jsp 매핑

내 프로젝트 구조는



    WebContent 
    + META-INF 
    - WEB-INF 
     - jsp 
     index.jsp 
     login.jsp 
     +lib 
     springMVC-servlet.xml 
     web.xml 

의 Web.xml




    <display-name>spring</display-name> 
     <servlet> 
      <servlet-name>springMVC</servlet-name> 
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
      <load-on-startup>1</load-on-startup> 
     </servlet> 

    <servlet-mapping> 
     <servlet-name>springMVC</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 
    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 
    </web-app> 

springMVC-servlet.xml에



    <?xml version="1.0" encoding="UTF-8"?> 
    <beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> 

     <context:component-scan 
      base-package="web.controller" /> 

    <!-- Enabling Spring MVC configuration through annotations --> 
    <mvc:annotation-driven /> 

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

HomeController

0 I는 index.jsp에서 다음 코드를 가지고 http://localhost:8080/Spring3/

로드 할 수 있어요 -



    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
    <%@ page language="java" contentType="text/html; charset=UTF-8" 
     pageEncoding="UTF-8"%> 
    <html> 
    <head> 
    <title>Login</title> 
    </head> 
    <body> 
    <c:url value="login.jsp" var="somevar" /> 
    <h1>Click here to </h1> <a href= "${somevar}">Login</a> 
    </body> 
    </html> 

을 그러나 나는 로그인 페이지로 연결되는 링크를 클릭 할 때 - 난 404 페이지를 얻을.

나는 무엇이 잘못 될지 잘 모르겠다. 아무도 나의 매핑이 잘못되어 가고있는 곳을 찾아 낼 수 있도록 도와 줄 수 있을까?

+0

있는 것으로 <c:url value="login" var="somevar" />를 작성해야, 스프링 컨트롤러 매핑을 사용합니다. –

답변

6

의 index.jsp에 당신이 당신의 controler를 당신은 클라이언트에 액세스 할 JSP 페이지에 직접 연결하고 매핑 @RequestMapping(value="/login")에게

+0

고마워 ... 그게 도움이 :) – user1755645