You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by 钟原froast <fr...@gmail.com> on 2007/07/17 11:36:58 UTC
[S2]struts2 validation error message problem
hi, this is my first web-based project using struts2.0. I met a problem when
using the validation . It seems the error message haven't been cleared and
each time I submit the form, then the error message was added after the
previous error message, it means if i submit 10 times, then there will
display 10 error message, 10 of the same. any help would be appreciated.
struts-app.xml:
<package name="account" namespace="/" extends="default">
<global-results>
<result name="input">jsp/account/account.jsp</result>
<result name="login_input">index.jsp</result>
</global-results>
<action name="account_save" method="save" class="AccountAction">
<interceptor-ref name="myStack"/>
</action>
<action name="account_*" method="{1}" class="AccountAction" >
<result name="create_success">/jsp/message.jsp</result>
<result name="create_failed">/jsp/message.jsp</result>
<result name="delete_success">/jsp/message.jsp</result>
<result name="wellcome">test.jsp</result>
<result name="list">jsp/account/userList.jsp</result>
<result name="account_role">jsp/account/userRole.jsp</result>
<result name="person_input">jsp/account/personSet.jsp</result>
</action>
</package>
AccountAction:
Jsp:
validation.xml
see the files.
the error message look just like this;
*string length shoule be 4-10 *string length shoule be 4-10 *string length
shoule be 4-10 *string length shoule be 4-10 *string length shoule be
4-10 *string
length shoule be 4-10 *string length shoule be 4-10 *string length shoule be
4-10 *string length shoule be 4-10 *string length shoule be 4-10
答复: [S2]struts2 validation error message problem
Posted by chenshibing <ch...@lifeisgreat.com.cn>.
You should modify your bean definition,
If you’re using spring 2.0.x,
<bean id=” AccountAction” class=”com.xxx.AcountAction” scope=”prototype”>
….
</bean>
Spring 1.xx
<bean id=”AccountAction” class=”com.xxxAccountAction” singleton=”false”>
</bean>
That ensure a new action was constructed every time a new request was sent, not a singleton
Action bean.
Crazyreal
_____
发件人: 钟原froast [mailto:froast@gmail.com]
发送时间: 2007年7月17日 17:37
收件人: user@struts.apache.org
主题: [S2]struts2 validation error message problem
hi, this is my first web-based project using struts2.0. I met a problem when using the validation . It seems the error message haven't been cleared and each time I submit the form, then the error message was added after the previous error message, it means if i submit 10 times, then there will display 10 error message, 10 of the same. any help would be appreciated.
struts-app.xml:
<package name="account" namespace="/" extends="default">
<global-results>
<result name="input">jsp/account/account.jsp</result>
<result name="login_input">index.jsp</result>
</global-results>
<action name="account_save" method="save" class="AccountAction">
<interceptor-ref name="myStack"/>
</action>
<action name="account_*" method="{1}" class="AccountAction" >
<result name="create_success">/jsp/message.jsp</result>
<result name="create_failed">/jsp/message.jsp</result>
<result name="delete_success">/jsp/message.jsp</result>
<result name="wellcome"> test.jsp</result>
<result name="list">jsp/account/userList.jsp</result>
<result name="account_role">jsp/account/userRole.jsp</result>
<result name="person_input">jsp/account/personSet.jsp</result>
</action>
</package>
AccountAction:
Jsp:
validation.xml
see the files.
the error message look just like this;
*string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10 *string length shoule be 4-10