Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: form submission problem in struts2 (release 2.0.5) j4

Ian Roughley

2007-02-13

Replies:

I would create a constructor in the action, and place a
breakpoint/logging statement in there to make sure the correct action is
beng called. In the HTML you have:

<s:form action="Logon" name="login_form" >

So the action should be /Logon.action, but your configuration is:

<action name="Logon_*" method="{1}" class="packagename.Logon">

Which would seen to imply that the action attribute in the form should
be "Logon_login".

/Ian


serhat tanrikut wrote:
> Hi All,
>
> I am evaluating struts2 and have developed a sample application using j4 similar to builtin struts2-blank application.When I submit jsp form the fallowing error occured:
>    ...
>    ...
>    SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception catched: Error setting expression 'password' with value '[Ljava.lang.String;@(protected)'
> Feb 13, 2007 7:24:19 PM com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters
> SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception catched: Error setting expression 'username' with value '[Ljava.lang.String;@(protected)'
>
>  ....
> ....
>
>   I have dropped these jar to WEB-INF/lib directory
>
>       * antlr-2.7.2.jar
>       * backport-util-concurrent-3.0.jar
>       * commons-beanutils-1.7.0.jar
>       * commons-chain-1.1.jar
>       * commons-logging-1.0.4.jar
>       * commons-validator-1.3.0.jar
>       * freemarker-2.3.8.jar
>       * ognl-2.6.9.jar
>       * oro-2.0.8.jar
>       * retrotranslator-runtime-1.2.0.jar
>       * retrotranslator-transformer-1.2.0.jar
>       * struts2-api-j4-2.0.5.jar
>       * struts2-core-j4-2.0.5.jar
>       * xwork-j4-2.0.0.jar
>
> ======================================================      
> and my jsp is
>
> <%@(protected)"
>    pageEncoding="UTF-8"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <%@(protected)" %>
> <html>
>    <head>
>       <title>Please Login</title>
>    </head>
>    <body>
>     <s:form action="Logon" name="login_form" >
>        <s:textfield label="%{getText('username')}" name="username"/>
>        <s:password label="%{getText('password')}" name="password" />
>        <s:submit />
>       </s:form>    
>    </body>
> </html>
>
> ======================================================
>
> and struts.xml is
>
> <package name="login" extends="struts-default">
>         <action name="index" class="packagename.IndexAction">
>         <result name="success">index.jsp</result>
>       </action>
>       <action name="Logon_*" method="{1}" class="packagename.Logon">
>         <result name="success">result.jsp</result>
>         <result name="input">login.jsp</result>
>       </action>
>    </package>
>  
> =======================================================
>  and Logon.java is
>      
> public class Logon extends ActionSupport {
>
>    
>    private static final long serialVersionUID = -178540847931051617L;
>    
>    
>    
>    public static final String loggedIn = "You have loggedin successfully ...";
>    public static final String notLoggedIn = "Login failed ...";
>    public static final String _userName = "admin";
>    public static final String _password = "admin";
>    
>    
>    
>    public String execute() throws Exception {
>       if (isInvalid(getUsername())) return INPUT;
>       if (isInvalid(getPassword())) return INPUT;
>       setMessage(this.login(getUsername(),getPassword()));
>       return SUCCESS;
>    }
>
>    private boolean isInvalid(String value) {
>       return (value == null || value.length() == 0);
>    }
>    
>    private String login(String _username,String _password){
>      
>       if(_username.equalsIgnoreCase(Logon._userName) &&
>            _password.equalsIgnoreCase(Logon._password))
>         return loggedIn;
>       else
>         return notLoggedIn;
>      
>    }
>    private String message;
>    private String username;
>    private String password;
>
>    public void setMessage(String message){
>       this.message = message;
>    }
>
>    public String getMessage() {
>       return message;
>    }
>
>    private String getPassword() {
>       return password;
>    }
>
>    private void setPassword(String password) {
>       this.password = password;
>    }
>
>    private String getUsername() {
>       return username;
>    }
>
>    private void setUsername(String username) {
>       this.username = username;
>    }
> }
>
> =================================================
>
> Is there any problem in jars or any configuration problem? If somebody has developed a sample application using struts2 j4 version ,Can he/she send me source codes
>
>  regards
>
>
>
> ---------------------------------
> Don't pick lemons.
> See all the new 2007 cars at Yahoo! Autos.
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.