I have enough nuts to crack here. I tried to integrate the mentioned 3 technologies into our webapp. We want to use
- Spring web
- Spring MVC as a viewing technology (with freemarker)
- Spring Security as a Security Level
But no matter how I set up my web.xml and other context files, I can't get everything to work at the same time. Everything will work in my current configuration except SpringSecurity will not intercept URL patterns
Some search queries (and common sense) told me that a problem with DispatcherServlet and ContextLoaderListener could be a problem.
So, here are my configurations. (Sorry for so much text and thanks for reading):
web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dw-manager-context.xml</param-value>
</context-param>
<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>
<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>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
My servlet-context.xml:
<context:component-scan base-package="dw.manager" />
<tx:annotation-driven transaction-manager="transactionManager" />
<mvc:annotation-driven />
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
</bean>
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
</bean>
-context.xml:
<context:annotation-config />
<import resource="deployment-setup.xml" />
<import resource="spring-security-context.xml" />
<import resource="dw-manager-datasource.xml" />
<import resource="classpath:dw-security-context.xml" />
Spring -Security-context.xml:
<http pattern="/login" security="none" />
<http pattern="/accessDenied" security="none" />
<http pattern="/" security="none" />
<http use-expressions="true" access-denied-page="/accessDenied">
<intercept-url pattern="/*" access="hasRole('ROLE_USER')" />
</http>
manager-datasource ...
, , , .;)
:
ContextLoaderListener, SpringSecurity. ConfigLocation, , ContextLoaderListener. , applicationContext.xml. , contextConfigLocation? , , , beans .?
edit2
, , SpringSecurity webapp (ContextLoaderListener) , - . , , spring , "", , .