I have struts2.xml definition like this:
<action name="/template">
<param name="body">/common/test.jsp</param>
<param name="header">/page/header.do</param>
<param name="footer">/page/footer.do</param>
<result name="success" type="tiles">/test.tiles</result>
</action>
In Tiles2:
<definition name=".default" template="/Template.jsp">
<put-attribute name="header" value="/page/header.do"/>
<put-attribute name="menu" value="/page/menu.do/>
<put-attribute name="body" value="/page/home.do"/>
<put-attribute name="footer" value="/page/footer.do"/>
</definition>
<definition name="/test.tiles" extends=".default">
<put-attribute name="body" value="body123"/>
</definition>
Xform:
<div id="header">
<include page="${header}"/>
</div>
<div id="body">
<include page="${body}"/>
</div>
<div id="footer">
<include page="${footer}"/>
</div>
I can't get the values(${body}, ${footer}, {header}) here. Whenever I requested this xflow I'm getting the blank page.
Web.xml:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
Please let me know if anything wrong with my configuration.
Appreciate your help.
Thanks
Related
I am new to tiles.I have configured my tiles.xml in following way:
<tiles-definitions>
<definition name="baseLayout" template="/template/BaseLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/template/Header.jsp" />
<put-attribute name="menu" value="/template/Menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/template/Footer.jsp" />
</definition>
<definition name="/addCustomer.tiles" extends="baseLayout">
<put-attribute name="title" value="Customer Form" />
<put-attribute name="body" value="/addCustomer.jsp" />
</definition>
</tiles-definitions>
My struts.xml is as follows:
<struts>
<constant name="struts.convention.action.includeJars" value=".*?\.jar(!/|/)?" />
<constant name="struts.convention.action.fileProtocols" value="jar,zip" />
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="addCustomer" class="com.adv.web.action.CustomerAction" method="addCustomer">
<result name="addCustomer" type="tiles">/addCustomer.tiles</result>
</action>
</package>
</struts>
I have configured web.xml as follows:
<context-param>
<param-name>
org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
</param-name>
<param-value>
/WEB-INF/tiles/tiles.xml
</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.adv.web.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
I have added struts2-tiles-plugin in pom.xml file.
when I am hittng following url:
localhost:7001/AddStrutsViewer-1.0/addCustomer
I am getting following exception
INFO: Publishing TilesContext for context:
org.apache.struts2.tiles.StrutsWildcardServletApplicationContext
org.apache.tiles.definition.NoSuchDefinitionException: Cannot find definition named 'addCustomer.tiles'
Can anyone figure out the issue?
/addCustomer.tiles
should be
addCustomer.tiles
instead
here my development settings before I start with my problem:
Struts 2: 2.3.20.1
Tiles 2: 2.0.6
Struts2-DoJo-Plugin: 2.3.20.1
Struts2-JQuery-Plugin: 3.7.1
TomEE 7.0.55
Java 8: 1.8.0_25
IDE: IntelliJ 2016.2 Ultimate
Now my problem:
I want to use the DateTimePicker in Struts2-Dojo or *-JQuery, but for both API I get false paths in the generated HTML sides.
Look at these pictures what my results are:
Struts 2 - DOJO (1st Browser view, 2nd HTML src)
Struts 2 - JQuery (1st Browser view, 2nd HTML src)
You see my problem? The double dashes? Why did Struts that? Is that a problem with Tiles?
I need only one dash, I looked up on this community before on this link:
Relative Path in Struts 2 - DOJO
... and test this (you can see that under BaseLayout.jsp below) and it doesn't work for my problem.
Here my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Struts Tiles 2 Demo</display-name>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
The struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.devMode" value="false"/>
<!--suppress InjectedReferences -->
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<default-action-ref name="start"/>
<action name="start">
<result name="success" type="tiles">index</result>
<result name="error" type="tiles">err404</result>
</action>
<action name="err404">
<result name="success" type="tiles">err404</result>
</action>
<action name="dbTest">
<result name="success" type="tiles">dbTest</result>
<result name="error" type="tiles">err404</result>
</action>
<action name="dtpJQ">
<result name="success" type="tiles">dtpJQ</result>
<result name="error" type="tiles">err404</result>
</action>
</package>
</struts>
The tiles.xml:
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="baseLayout" template="/WEB-INF/tiles/layouts/BaseLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/tiles/parts/Header.jsp" />
<put-attribute name="menu" value="/WEB-INF/tiles/parts/Menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/tiles/parts/Footer.jsp" />
<!-- only true or false -->
<put-attribute name="isDojoActive" value="false" />
<put-attribute name="isJQueryActive" value="false" />
</definition>
<definition name="index" extends="baseLayout">
<put-attribute name="title" value=".: 1st Steps Base Layout Struts 2 :." />
<put-attribute name="body" value="/WEB-INF/tiles/body/start.jsp" />
</definition>
<definition name="err404" extends="baseLayout">
<put-attribute name="title" value=".: Test Error 404 Page :." />
<put-attribute name="body" value="/WEB-INF/tiles/errorPages/404.jsp" />
</definition>
<definition name="dbTest" extends="baseLayout">
<put-attribute name="title" value=".: DB Test :." />
<put-attribute name="body" value="/WEB-INF/tiles/tableViews/dbTest.jsp" />
</definition>
<definition name="dtpTest" extends="baseLayout">
<put-attribute name="title" value=".: Date Time Picker Test - START :." />
<put-attribute name="body" value="/WEB-INF/tiles/body/testDTP.jsp" />
<put-attribute name="isDojoActive" value="true" />
</definition>
<definition name="dtpJQ" extends="baseLayout">
<put-attribute name="title" value=".: DTP JQ TEST :." />
<put-attribute name="body" value="/WEB-INF/tiles/modules/dateTimePickerJQuery.jsp" />
<put-attribute name="isJQueryActive" value="true" />
</definition>
<definition name="dateTimePicker" extends="baseLayout">
<put-attribute name="title" value=".: Date Time Picker Test :." />
<put-attribute name="body" value="/WEB-INF/tiles/modules/dateTimePicker.jsp" />
</definition>
</tiles-definitions>
BaseLayout.jsp:
<%#page contentType="text/html;charset=UTF-8" language="java" %>
<%#taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%#taglib prefix="s" uri="/struts-tags" %>
<%#taglib prefix="sx" uri="/struts-dojo-tags" %>
<%#taglib prefix="sj" uri="/struts-jquery-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><tiles:insertAttribute name="title" ignore="true" /></title>
<style type="text/css">#import url(/css/main.css);</style>
<s:set var="isDojoActive"><tiles:getAsString name="isDojoActive" /></s:set>
<s:set var="isJQueryActive"><tiles:getAsString name="isJQueryActive" /></s:set>
<s:if test='%{#isDojoActive.equals("true")}'>
<sx:head baseRelativePath="/struts/dojo" debug="true" parseContent="false" />
</s:if>
<s:if test='%{#isJQueryActive.equals("true")}'>
<sj:head />
</s:if>
</head>
<body>
<div class="container">
<div id="baseLeft"><tiles:insertAttribute name="menu" /></div>
<div id="baseRight">
<div class="inner-content header center"><tiles:insertAttribute name="header" /></div>
<div class="inner-content body"><tiles:insertAttribute name="body" /></div>
<div class="inner-content footer right"><tiles:insertAttribute name="footer" /></div>
</div>
</div>
</body>
</html>
I found the mistake:
My TomEE configuration under IntelliJ IDEA:
The missing root/application context.
Below are my resources.
a) 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>ezviewocean</display-name>
<description>EZ-View Ocean</description>
<context-param>
<param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts-prepare</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
b) tiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="baseLayout" template="/baseLayout.jsp">
<put-attribute name="title" value="Template"/>
<put-attribute name="header" value="/header.jsp"/>
<put-attribute name="leftmenu" value="/leftmenu.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
<put-attribute name="footer" value="/footer.jsp"/>
</definition>
<definition name="view" extends="baseLayout">
<put-attribute name="title" value="View"/>
<put-attribute name="body" value="/viewBody.jsp"/>
</definition>
<definition name="assign" extends="baseLayout">
<put-attribute name="title" value="Assign"/>
<put-attribute name="body" value="/assignBody.jsp"/>
</definition>
</tiles-definitions>
c) struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true"/>
<constant name="struts.custom.i18n.resources" value="ApplicationResources"/>
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="login" method="execute"
class="com.schenker.ocean.actions.LoginAction">
<result name="success" type="tiles">baseLayout</result>
<result name="input">/login.jsp</result>
<result name="fail">/login.jsp</result>
</action>
</package>
</struts>
I have
tiles-api-2.2.2.jar,
tiles-core-2.2.2.jar,
tiles-jsp-2.2.2.jar,
tiles-servlet-2.2.2.jar,
tiles-compact-2.2.2.jar,
struts2-tiles-plugin-2.2.16.3.jar
and some other jars in my web-inf/lib folder.
Also, below is the baseLayout.jsp
<%# taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><tiles:insertAttribute name="title" ignore="true" />
</title>
</head>
<body>
<tiles:insertAttribute name="header" /><br/>
<hr/>
<tiles:insertAttribute name="leftMenu" /><br/>
<hr/>
<tiles:insertAttribute name="body" /><br/>
<hr/>
<tiles:insertAttribute name="footer" /><br/>
</body>
</html>
I can post other pages or screenshots if needed. Below is the error i get when i try to run this application.
Struts has detected an unhandled exception:
Messages:
org.apache.tiles.template.AttributeResolver
org/apache/tiles/template/AttributeResolver
java.lang.NoClassDefFoundError: org/apache/tiles/template/AttributeResolver
File: org/apache/catalina/loader/WebappClassLoader.java
Line number: 1,680
Answer: in my case using the tilesServelet worked. Check the comments below.
I followed the below example to integrated the spring security in wicket.
https://github.com/thombergs/wicket-spring-security-example.
I changed spring-security.xml file to configure the concurrency control as follows.
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
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/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true" create-session="never" auto-config="true">
<!-- <custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter"
/> -->
<!-- <custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter" /> -->
<intercept-url pattern="/" access="permitAll"
requires-channel="https" />
<intercept-url pattern="/home" access="permitAll"
requires-channel="https" />
<intercept-url pattern="/login" access="permitAll"
requires-channel="https" />
<intercept-url pattern="/**/*.png" access="permitAll"
requires-channel="https" />
<intercept-url pattern="/**/*.css" access="permitAll"
requires-channel="https" />
<intercept-url pattern="/secure/extreme/**" access="hasRole('supervisor')"
requires-channel="https" />
<intercept-url pattern="/secure/**" access="isAuthenticated()"
requires-channel="https" />
<!-- <intercept-url pattern="/**" access="permitAll" requires-channel="https"
/> -->
<!-- the login page is a wicket page mounted in WicketApplication.init() -->
<form-login login-page="/login" default-target-url='/home'
always-use-default-target='true' />
<session-management>
<concurrency-control max-sessions="1"
session-registry-alias="authenticationManager" expired-url="/login"
error-if-maximum-exceeded="true" session-registry-ref="sessionRegistry" />
</session-management>
<!-- <session-management session-authentication-error-url="/login"> <concurrency-control max-sessions="1" error-if-maximum-exceeded="true" /> </session-management> -->
<!-- <session-management invalid-session-url="/login" /> -->
</http>
<!-- <beans:bean id="myAuthFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<beans:property name="sessionAuthenticationStrategy" ref="sas" /> <beans:property name="authenticationManager" ref="authenticationManager" /> </beans:bean> -->
<authentication-manager alias="authenticationManager">
<authentication-provider>
<user-service>
<user name="rod" password="koala" authorities="supervisor, teller, user" />
<user name="dianne" password="emu" authorities="teller, user" />
<user name="scott" password="wombat" authorities="user" />
<user name="peter" password="opal" authorities="user" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="concurrencyFilter"
class="org.springframework.security.web.session.ConcurrentSessionFilter">
<beans:property name="sessionRegistry" ref="sessionRegistry" />
<beans:property name="expiredUrl" value="/login" />
</beans:bean>
<!-- <beans:bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" /> <beans:property name="maximumSessions" value="1" /> </beans:bean> -->
<beans:bean id="sessionRegistry"
class="org.springframework.security.core.session.SessionRegistryImpl" autowire="default" />
<!-- This filter is responsible for storing the SecurityContextHolder between
requests. Also see SecureWebSession.authenticate(). -->
<beans:bean id="securityContextPersistenceFilter" class="org.springframework.security.web.context.SecurityContextPersistenceFilter" />
</beans:beans>
web.xml file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<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">
<display-name>wicket-spring-security-example</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-security.xml
</param-value>
</context-param>
<listener>
<listener- class>org.springframework.web.context.ContextLoaderListener</listener- class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>wicket.wicket-spring-security-example</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>org.wickedsource.WicketApplication</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>wicket.wicket-spring-security-example</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
</web-app>
My Questions :
1) Concurrency control is not working with the above configuration. I am able to login multiple browsers.
2) Single sign-in per user(I mean, the user 'x' is logged in, if the same user('x') logged in again. Here I want invalidate the previously logged in session). How can I achieve this.
1) It probably doesn't work since the Session Management in the example is handled by Wicket and not by Spring Security, so you must find a way to enable this in Wicket.
2) The Wicket Session class has the method replaceSession() that you can use to create a new session on login. Try this.
I was trying to figure out how can I implement a simple application using Spring security 3.1 and struts2.
Actualy, I want to provide a custom UserDetailsService implementation, and provide also my own login page.
Though I was working on this little simple application for more than 10 days, I couldn't make it work... And the official documentation didn't explain clearly how to do it.
In the configuration below, if I use the default login page provided by Spring security, everything works correctly. When I try to use mine, I cannot log on even though the
loadUserByUsername method is called and a valid UserDetails is returned from the database, and I stick on the login page.
In the console I get the message:
WARNING: No configuration found for the specified action: '/myApplication/j_spring_security_check' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
So maybe I have a namespace problem ?
Here is my code
Web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value> /WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-security.xml </param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>public/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<package name="public" namespace="/public" extends="struts-default">
<action name="login" class="loginAction">
<result name="success">/secure/welcome.jsp</result>
<result name="input">login.jsp</result>
</action>
<action name="register" class="registerAction">
<result name="success">confirm_register.jsp</result>
<result name="input">register.jsp</result>
</action>
</package>
<package name="secure" namespace="/secure" extends="struts-default">
<action name="add" class="myApplication.action.UserAction" method="add">
<result name="success">welcome.jsp</result>
</action>
<action name="list" class="myApplication.action.UserAction" method="list">
<result name="success">list.jsp</result>
</action>
</package>
applicationContext-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" 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.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<global-method-security pre-post-annotations="enabled">
<!-- AspectJ pointcut expression that locates our "post" method and applies
security that way <protect-pointcut expression="execution(* bigbank.*Service.post*(..))"
access="ROLE_TELLER"/> -->
</global-method-security>
<http pattern="/resources" security="none" />
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/public/*" access="permitAll" />
<intercept-url pattern="/logout" access="permitAll" />
<intercept-url pattern="/secure/*"
access="hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/denied" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/" access="hasRole('ROLE_USER')" />
<form-login login-page="/login.jsp"
authentication-failure-url="/login.jsp" />
<access-denied-handler error-page="/denied" />
<logout invalidate-session="true" logout-success-url="/logout/success"
logout-url="/logout" />
</http>
<authentication-manager>
<authentication-provider user-service-ref="customUserDetailsService" />
</authentication-manager>
login.jsp
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%# taglib prefix="s" uri="/struts-tags"%>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<h1>Identification</h1>
<s:form action="/myApplication/j_spring_security_check" method="post">
<s:actionerror />
<s:textfield label="Username" name="username"/>
<s:textfield label="Password" name="password"/>
<s:submit name="submit" />
</s:form>
</body>
</html>
Any idea/advice ?
First of all use <s:form> tag properly http://struts.apache.org/2.x/docs/url.html or use HTML form tag. Second default spring-security user name and password fields for form based authentication are j_username and j_password.
So change you JSP to something like that and see if this works.
<form action="j_spring_security_check" method="post">
<table>
<s:textfield name="j_username" autofocus="autofocus" />
<s:password name="j_password" />
<s:submit/>
</table>
</form>