2013-01-14 3 views
0

Spring 웹 애플리케이션에 대한 사용자 정의 로그인 페이지를 작성하는 데 문제가 있습니다.봄 사용자 정의 로그인 페이지에 페이지를 표시 할 수 없습니다.

기본 로그인 양식은 정상적으로 작동합니다. 하지만

**<form-login login-page="/login" />** 

를 추가 할 때 응용 프로그램은 "페이지를 표시 할 수 없습니다"오류 그러나없이 실행이 나타납니다.

아이디어가 있으십니까? 감사

다음

내 web.xml에 다음

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <display-name>testweb</display-name> 

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

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

    <!-- 
     - Loads the root application context of this web app at startup. 
    --> 
    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <!-- 
     - Location of the XML file that defines the root application context 
     - Applied by ContextLoaderListener. 
     --> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> 
      /WEB-INF/applicationContext-security.xml 
     </param-value> 
    </context-param> 

    <!-- Processes application requests --> 
    <servlet> 
     <servlet-name>dispatcher</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 

     <load-on-startup>1</load-on-startup> 
    </servlet>  

    <servlet-mapping> 
     <servlet-name>dispatcher</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 


</web-app> 

내 스프링 설정 파일 여기

<?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:tx="http://www.springframework.org/schema/tx" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 

    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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
"> 

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> 

    <!-- Scans within the base package of the application for @Components to configure as beans --> 
    <!-- @Controller, @Service, @Configuration, etc. --> 
    <context:component-scan base-package="myPACKAGE" /> 
    <!-- Enables the Spring MVC @Controller programming model --> 
    <mvc:annotation-driven /> 


<!-- Resolve logical view names to .jsp resources in the /WEB-INF/views directory --> 
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <property name="prefix" value="/WEB-INF/views/" /> 
    <property name="suffix" value=".jsp" /> 
</bean> 
</beans> 

내 봄 보안 파일

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans" 

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 
    xmlns="http://www.springframework.org/schema/security" 
    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/security http://www.springframework.org/schema/security/spring-security-3.1.xsd 
"> 

    <http auto-config="true"> 
     <intercept-url pattern="/*" access="ROLE_USER" /> 
     **<form-login login-page="/login" />** 

    </http> 

    <authentication-manager> 
     <authentication-provider> 
      <user-service> 
       <user name="myuser" password="mypwd" authorities="ROLE_USER" /> 
      </user-service> 
     </authentication-provider> 
    </authentication-manager> 

</beans:beans> 

사용자 정의 로그인 페이지입니다입니다 WEB-INF/views/login.jsp 내의 login.jsp

+0

'리소스를 찾을 수 없음'또는 보안 관련 예외가 발생하는지 알려줄 수 있습니까? – Greg

답변

0
  1. 로그인 무엇입니까? HTML? JSP로?/login이 아닌 로그인 페이지의 URI (예 : /login.html)를 작성해야합니다. "=

< HTTP 패턴 ="/ 로그인/** "보안 :

  • 시도는 익명 사용자가 볼 수 있도록하는 하위 디렉토리 (예 :/로그인)에 로그인 페이지를 넣어 없음 "/>

    다음

    <security:form-login 
        login-page="/login/login.jsp" 
         ... 
    
  • 0

    당신은 그래서 당신은 스프링 MVC 사용한다고 가정합니다 스프링을 사용했다, 당신은

    을 추가 한
    <!-- selects a static view for rendering without the need for an explicit controller --> 
    <mvc:view-controller path="/login" view-name="login"/> 
    

    귀하의 webmvc 구성에.

    은 또한 당신은 로그인 페이지로 익명 사용자에 대한 액세스 권한을 부여 할 필요가

    <definition extends="default" name="/login"> 
        <put-attribute name="body" value="/WEB-INF/views/login.jspx"/> 
    </definition> 
    
    1

    추가 할 수 있습니다 로그인 페이지 매핑을 변경합니다. 요소

    <intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" /> 
    

    편집하여 HTTP에 다음 코드를 추가합니다. 순서는 중요합니다.

    <intercept-url pattern="/*" access="ROLE_USER" /> 
    
    0

    이 내가 생각해야한다 : 그것은 전에이 줄을 를 삽입해야합니다.

    <intercept-url pattern="/login.htm" access="permitAll()"/> 
        <form-login login-page="/login.htm"      
           authentication-failure-url = "/positionViewer/login.htm?login_error=1" /> 
    
    관련 문제