Spring security /j_spring_security_login 404 error

361 views Asked by At

I'm trying to using Spring security, but now I cannot find what is the problem. Now I can't find why this /j_spring_security_login not link to login page.

<a href="<c:url value='/j_spring_security_login'/>"><button>로그인</button></a>

I expected to go to /login page when I click this link, but only 404 page showing. my web.xml is like this

<?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_3_0.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <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>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring-security.xml
            /WEB-INF/repository.xml
        </param-value>
    </context-param>

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

    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

and spring-security.xml

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

    <sec:http auto-config="true" use-expressions="true">
        <sec:intercept-url pattern="/admin/**" access="hasAuthority('ROLE_ADMIN')"/>
        <sec:intercept-url pattern="/account/**" access="hasAuthority('ROLE_USER')"/>
        <sec:intercept-url pattern="/**" access="permitAll"/>
        <sec:form-login 
            login-page="/login"
            default-target-url="/welcom"
            authentication-failure-url="/login?error"/>
        <sec:logout logout-url="/login?logout" />
    </sec:http>

    <sec:authentication-manager>
        <sec:authentication-provider>
            <!-- <jdbc-user-service data-source-ref="dataSource" 
                users-by-username-query="SELECT username, password, enabled FROM USER WHERE username = ?"
                authorities-by-username-query="SELECT username, role FROME USER_ROLE WHERE username = ?" /> -->
            <sec:user-service>
                <sec:user name="admin" password="admin" authorities="ROLE_USER" />
            </sec:user-service>
        </sec:authentication-provider>
    </sec:authentication-manager>

</beans:beans> 

Sorry for my bad English. If you want, here is my github page

0

There are 0 answers