struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <>
Subject Re: Spring Struts problem
Date Fri, 25 Mar 2016 06:39:15 GMT
2016-03-24 22:25 GMT+01:00 José Antonio Delgado Trujillo <>:
>> You must define also scope="prototype" as Struts actions cannot be singletons
> There is nothing about that in the tutorial
> <>

Ups.... it's a mistake, I will fix it. Actions cannot be singletons as
they must be created on each request. If you will have them as
singletons they will share state between requests/users and this can
produce unpredictable problems

>> You shouldn't mix Struts versions.
> Sure but there is not 2.3.28 version to struts-spring-plugin.
> The new time i’ll use the lasted version 2.5 of the arquetype.

it's there

>> Can you share struts.xml as well?
> Upss!!
> I found the mistake, a question of uppercase (in the struts.xml the name of the class
action began with lowercase). I’m stupid, i realised when i saw the debug error. SORRY for
your time !!!
> Now it runs and without the scope.
> <?xml version="1.0" encoding="UTF-8" ?>
>         "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
>         "">
> <struts>
>     <constant name="struts.devMode" value="true"/>
>     <constant name="struts.ui.theme" value="KUTheme"/>
>     <package name="basicstruts2"  extends="struts-default">
>         <action name="index">
>             <result>/index.jsp</result>
>         </action>
>         <action name="edit" class="pfc.struts2.form.action.EditAction" method="input">
>                 <result name="input">/edit.jsp</result>
>         </action>
>                 <action name="save" class="pfc.struts2.form.action.editAction" method="execute">
>                         <result name="success">/thankyou.jsp</result>
>                         <result name="input">/edit.jsp</result>
>                 </action>
>     </package>
> </struts>

It's ok but you must use action's bean id instead of class name in
struts.xml, as it was shown in the tutorial

<action name="edit" class="editAction" method="input">
    <result name="input">/edit.jsp</result>

it must be that way as Struts will ask Spring to create a bean based
on "class" attribute - Spring will create an action using just a full
class name but this isn't what you want sometimes, ie. you can have
the same action class used twice but with different dependencies
that's why you should use "editAction" in "class" attribute.

+ 48 606 323 122

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message