spring security No WebApplicationContext found -
i new spring security
i have web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app 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_3_0.xsd" version="3.0"> <context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/applicationcontext-security.xml </param-value> </context-param> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.html</url-pattern> </servlet-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> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
applicationcontext-security.xml
<?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 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-3.0.xsd"> <http auto-config="true"> <intercept-url pattern="/register.html" access="is_authenticated_anonymously" /> <intercept-url pattern="/*" access="role_user, role_admin" /> <logout logout-url="/logout"/> </http> <beans:bean id="myuserdetailsservice" class="labas.spring.service.userdetailsimp"/> <authentication-manager> <authentication-provider user-service-ref='myuserdetailsservice'/> </authentication-manager>
some why when run
java.lang.illegalstateexception: no webapplicationcontext found: no contextloaderlistener registered?
what wrong?
you haven't declared root webapp context - you've added contextconfiglocation
, not listener uses it:
<listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener>
Comments
Post a Comment