春春+ +的安全性瓷砖。如何设置表单登录瓷砖页面定义? [英] Spring+Spring security+tiles. How to set form-login with tiles page definition?
问题描述
我有spring_tiles Web应用程序,现在想春天的安全性添加到它:
I have spring_tiles web application and now trying to add spring security to it:
这是我TilesConfig.xml的和平:
That is a peace of my TilesConfig.xml:
<definition name="loginPage" extends="commonPage">
<put-attribute name="body" value="/WEB-INF/tiles/jsp/login_body.jsp" />
</definition>
下面我来春映射部分:
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="openSessionInViewInterceptor" />
</list>
</property>
<property name="mappings">
<props>
<prop key="/main.htm">mainController</prop>
<prop key="/category.htm">viewCategoryController</prop>
<prop key="/good.htm">goodController</prop>
<prop key="/registration.htm">registrationController</prop>
<prop key="/login.htm">?</prop>
</props>
</property>
</bean>
这是从的applicationContext-security.xml文件的一部分:
And here is a part from applicationContext-security.xml:
<http auto-config='true'>
<intercept-url pattern="/**" access="ROLE_USER" />
<intercept-url pattern="/css/**" filters="none"/>
<intercept-url pattern="/js/**" filters="none"/>
<intercept-url pattern="/login.htm*" filters="none"/>
<form-login login-page="/login.htm" />
</http>
但我不知道我应该怎么设置我的瓷砖页面定义的映射。在所有其他网页我用的控制器,但我想我不应该使用任何的LoginController在这种情况下,因为春季安全做到这一点吧。
But I wonder how should I set up my tiles page definition to the mapping. In all other pages I used controllers but I suppose I should not use any loginController in that case because Spring Security do that instead.
所以,这里是我的问题:如何映射瓷砖loginPage春天的安全范围内/login.htm
So, here is my question: how to map tiles loginPage to /login.htm within spring security?
推荐答案
我已经找到一种方法来做到这一点。在Spring配置我已经添加了这一点:
I've found a way to do it. In the spring config I've added this:
<bean id="loginController"
class="org.springframework.web.servlet.mvc.ParameterizableViewController">
<property name="viewName" value="loginPage" />
</bean>
和在映射相应补充一点:
And in the mapping accordingly add that:
<prop key="/login.htm">loginController</prop>
瓷砖和安全配置保持不变。
Tiles and security configurations remained the same.
这篇关于春春+ +的安全性瓷砖。如何设置表单登录瓷砖页面定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!