Reputation: 285
I want to make a CMS in Spring and I have problems setting up 2 dispatcher servlets. (Also I am new to spring)
And I want to have this structure:
app/...
(my site with all my pages)
app/cms/...
(my cms part of the site where I can manage my content)
So, I defined 2 dispatcher servlets:
<servlet>
<description></description>
<display-name>app</display-name>
<servlet-name>app</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
and
<servlet>
<description></description>
<display-name>cms</display-name>
<servlet-name>cms</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cms</servlet-name>
<url-pattern>/cms/*</url-pattern>
</servlet-mapping>
also with 2 xml files cms-servlet.xml
and app-servlet.xml
both with the correct package location and jsp resolver with correct location for jsp files
now I'm trying to set up security and a login form. My security-context.xml
:
<security:http use-expressions="true">
<security:intercept-url pattern="/cms/login" access="permitAll" />
<security:intercept-url pattern="/resources/**" access="permitAll" />
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/cms/**" access="isAuthenticated()" />
<security:intercept-url pattern="/**" access="denyAll" />
<security:form-login login-page="/cms/login" />
</security:http>
Problem is I get an error:
Mai 18, 2014 10:35:32 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/app/cms/login] in DispatcherServlet with name 'cms'
My custom login.jsp (of course with the correct tags for spring to process it) is under the cms jsp files. And the controller for login is in package that I defined in cms-servlet.xml
. If I change these 2:
<security:intercept-url pattern="/login" access="permitAll" />
<security:form-login login-page="/login" />
I get an error on my browser complaining about This webpage has a redirect loop
.
What is the problem ? Is how I set the 2 dispatcher servlets correct ?
PS: my Login Controller from cms package:
@RequestMapping("/login")
public String showLogin() {
return "login";
}
Upvotes: 0
Views: 80
Reputation: 2747
Because of the warning:
No mapping found for HTTP request with URI [/app/cms/login]
in DispatcherServlet with name 'cms'
does your controller map /cms
? Something like:
@Controller
@RequestMapping("/cms")
public class CmsController {
@RequestMapping("/login")
public String showLogin() {
return "login";
}
Upvotes: 1