struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john lee <sh_thorn_b...@yahoo.com>
Subject struts 2 validation if use with spring
Date Fri, 08 Mar 2013 04:48:31 GMT




Problem
 
I use struts2/spring 3 as integration, and need to use struts2
validation.xml as well, 
Basically, the action name in the login.jsp/struts.xml  is pseudo class name, but is implemented
in
the applicationContext.xml
In order to let validation.xml works, I defined  all the possible XXXvalidation.xml for both
matched
psesuo action class name and actually class name, but looks like no one works.
Is XXXvalidation.xml only works for struts2 actual class
name only? But not works if used in struts2/spring proxy action forward?
Pelase   advise.
 
john
 
 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce # cat
login.jsp

<%@ taglib prefix="s"
uri="/struts-tags"%>
<s:actionerror/>
<s:form action="signin">
<s:textfield name="loginId"
label="login"/>
<s:textfield name="password"
label="password"/>
<s:submit value="logint"/>
</s:form>                          
 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF
# cat applicationContext.xml
……
<bean
id="loginAction" class="neuco.AcctAction"
scope="prototype"> </bean>
........

 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes
# cat struts.xml

<!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD
Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">   
<struts>
    <package
name="default" extends="struts-default">
                 <action name="signin" class="loginAction">
                    <result
name="success">success.jsp</result>
                    <result
name="error">login.jsp</result>
                </action> 
 </package></struts>
 
 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/neuco
# cat AcctAction.java

package neuco;
public class AcctAction extends
ActionSupport {
  private
String loginId;
  private String password;
  public void setLoginId(String loginId) { this.loginId=loginId; }
  public void setPassword(String password) { this.password=password; }
  public String getLoginId() { return loginId; }
  public String getPassword() { return password; }
 
     public String execute() throws
Exception {
          Map
session=ActionContext.getContext().getSession();
          if (login.equals("test" ) ) {
           session.put("loginid",login_return);
           addActionMessage("Login
Success");
           return "success";
           }
        else
           addActionError("loginid/password
not match");
        return "error";
  }  
 
}       
 
 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes
# cat  Signin-Validation.xml

<!DOCTYPE validators PUBLIC
"-//Apache Struts//XWork Validator 1.0.3//EN"    "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators> 
     <field name="loginId"> 
         <field-validator
type="requiredstring">
            <param
name="trim">true</param> 
           <message="errors.required" />       
     </field-validator>
    </field>
</validators>   
 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes
# ls *Validation.xml
AcctAction-Validation.xml  LoginAction-Validation.xml  Signin-Validation.xml
 
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes/neuco
# ls *Validation.xml
AcctAction-Validation.xml  LoginAction-Validation.xml  Signin-Validation.xml
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message