javascript - unable to allow static resources in spring security 3 -
i unable allow static resources(like js,css,images) in spring security 3.below config file.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <bean id="authenticationentrypoint" class="org.springframework.security.web.authentication.loginurlauthenticationentrypoint"> <property name="loginformurl" value="/login.htm" /> </bean> <security:http security="none" pattern="/js/ajaxscript.js"/> <security:http security="none" pattern="/js/commonscript.js"/> <bean class="org.springframework.security.web.access.expression.defaultwebsecurityexpressionhandler" /> <security:http auto-config="false" entry-point-ref="authenticationentrypoint" disable-url-rewriting="true" use-expressions="true"> <security:custom-filter position="form_login_filter" ref="customauthenticationprocessingfilter" /> <!-- <security:intercept-url pattern="/js/jquery.min.js" access="isauthenticated()" /> --> <!-- <security:intercept-url pattern="/js/**/**" access="permitall" /> --> <security:intercept-url pattern="/displayadminpage.htm" access="hasrole('role_admin')" /> <security:access-denied-handler ref="accessdeniedhandler" /> </security:http> <security:authentication-manager alias="authenticationmanager"> <security:authentication-provider user-service-ref="customuserdetailservice"> </security:authentication-provider> </security:authentication-manager> <bean id="customuserdetailservice" class="com.qait.cdl.services.impl.usersecurityserviceimpl"> <property name="userdao" ref="userdao"/> </bean> <bean id="customauthenticationprocessingfilter" class="com.qait.cdl.services.impl.customauthenticationprocessingfilter"> <property name="authenticationmanager" ref="authenticationmanager" /> </bean> <bean id="accessdeniedhandler" class="org.springframework.security.web.access.accessdeniedhandlerimpl"> <property name="errorpage" value="/web-inf/jsp/customloginform/denied.jsp" /> </bean> </beans> i don't know wrong?i want js,images,css must bypass spring security.js files present in webapp/js , webapp/js/commonscript folder.images present in webapp/images folder.
below 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_2_5.xsd" id="webapp_id" version="2.5"> <display-name>cdl</display-name> <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> <servlet> <servlet-name>startupservlet</servlet-name> <servlet-class>com.qait.cdl.commons.startup.startupservlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>startupservlet</servlet-name> <url-pattern>/startupservlet.htm</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>redirect.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>cdl_env</param-name> <param-value>staging</param-value> </context-param> <listener> <listener-class>com.qait.cdl.commons.startup.cdlcontextlistner</listener-class> </listener> <!-- session timeout --> <session-config> <session-timeout>600</session-timeout> </session-config> <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> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <context-param> <param-name>contextconfiglocation</param-name> <param-value> web-inf/applicationcontext.xml <!-- web-inf/springsecurityconfig.xml --> web-inf/dispatcher-servlet.xml </param-value> </context-param> </web-app>
update:
from updated question problem static resource mapping. need add static resource mapping in spring configuration since requests passed dispatcher servlet.
need add following dispatcher-servelt.xml
<mvc:resources mapping="/js/**" location="/js/" />
Comments
Post a Comment