Search code examples
javaparametersstruts2model-driven

ParametersInterceptor Error in server console after submitting the form, when devMode is true


When I am submitting a form in Struts 2, I am getting the below ERROR in server console when devMode set to true. Though this is not impacting my functionality, not sure why this is occurring.

//Error msg

14:34:54,748 ERROR [com.opensymphony.xwork2.interceptor.ParametersInterceptor] (http-localhost/127.0.0.1:8080-1) ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'x' on 'class com.abc.LoginAction: Error setting expression 'x' with value '[Ljava.lang.String;@154cfc5'
14:34:54,749 ERROR [com.opensymphony.xwork2.interceptor.ParametersInterceptor] (http-localhost/127.0.0.1:8080-1) ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'y' on 'class com.abc.LoginAction: Error setting expression 'y' with value '[Ljava.lang.String;@114b526'

Below is the code snippet

// Login JSP
<s:form action="login">
<table>
    <tr><td>UserName : </td><td><s:textfield name="userid"/></td>
    <tr><td>Password : </td><td><s:password name="password"/></td>
    <tr><td></td><td><s:submit value="Submit" /></td>
</table>
</s:form>

Action class to handle the form submission

public class LoginAction implements ModelDriven<LoginForm> {
    private LoginForm theForm = new LoginForm();
    public LoginForm getModel() {
        return theForm;
    }
    public String execute() throws Exception {
        -----
        -----
    }
}

// POJO used for data binding.
public class LoginForm {
    private String userid;
    private String password;
    // Setters and Getters
    
}

Solution

  • You have extra parameters with the request, for that you don't have public accessors in the action class. But if you don't need that redundant parameters to be processed by the Struts interceptor then you can configure this interceptor to exclude these parameters.

    In the example Struts 2 ModelDriven Action how to exclude some properties from being updated you can find the code to do it using xml configuration. Other examples might use annotations config that are available in my answers.

    Where these extra parameters coming from is difficult to say, probably you have some input field of type image.