java - Struts 2 - Unexpected Exception caught setting 'xx' -


i trying submit unknown number input html form action class , fetch input parameter information using request method(used servletactioncontext) in action class.

but throwing

unexpected exception caught setting 'xx' on 'class classname error setting expression 'xx' value ['yy', ]

since input elements in form adding dynamically using js, not in position have getters , setters in action class.

how process action class without exceptions?

jsp:

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>team activity log</title> <script language="javascript"> function addrow(tableid) {  var table = document.getelementbyid(tableid);   var rowcount = table.rows.length;    var row = table.insertrow(rowcount);      var cell1 = row.insertcell(0);     var element1 = document.createelement("select");     element1=document.getelementbyid("sele").clonenode(true);     element1.type="select";     cell1.appendchild(element1);      var cell2=row.insertcell(1);     var element2 = document.createelement("input");     element2.type="text";     element2.setattribute("placeholder","e.g:1234");     cell2.appendchild(element2);      var cell3=row.insertcell(2);     var element3 = document.createelement("input");     element3.type="text";     element3.setattribute("placeholder","brief work");     cell3.appendchild(element3);      var cell4=row.insertcell(3);     var element4 = document.createelement("input");     element4.type="text";         element4.setattribute("placeholder","mm min");     cell4.appendchild(element4);       var cell5=row.insertcell(4);     var element5 = document.createelement("img");     element5.src="close.png";         element5.setattribute("id","delete");         element5.setattribute("onclick","changeimage(this)");     cell5.appendchild(element5);        } function changeimage(temp) { (temp.parentelement).parentelement.remove(); } function convert(tableid,temp2) { var table=document.getelementbyid(tableid); console.log(table.rows.length); var hidelement=document.getelementbyid(temp2); hidelement.setattribute("value",table.rows.length-1); for(var i=1;i<table.rows.length;i++) { var tt="tt"+i; var rf="rf"+i; var des="des"+i; var eff="eff"+i; console.log("executing function"); var elemen=table.rows[i].cells[0].queryselector("*"); elemen.setattribute("name",tt); elemen=table.rows[i].cells[1].queryselector("*"); elemen.setattribute("name",rf); elemen=table.rows[i].cells[2].queryselector("*"); elemen.setattribute("name",des); elemen=table.rows[i].cells[3].queryselector("*"); elemen.setattribute("name",eff); } } </script> </head> <body>     <input type="button" value="add row" onclick="addrow('matrix')" />     <%@ taglib uri="/struts-tags" prefix="s" %>     <s:url id="myactionurl" action="timesheetprocess" />     <form action=<s:property value="%{myactionurl}" />>      <input type="hidden" id="taskcount" value="5"> <table id="matrix"> <tr>     <th>task type</th>     <th>reference id</th>     <th>description</th>     <th>efforts</th>     <th></th>   </tr>   <tr>   <td>   <select id="sele">   <option value="" disabled selected>select option</option>            <option value="sr">sr</option>            <option value="cr">cr</option>            <option value="alm">alm</option>            <option value="incident">incident</option>             <option value="other">other</option>    </select></td>    <td>    <input type="text" placeholder="e.g:1234"/>    </td>    <td>    <input type="text" placeholder="brief work"/>    </td>    <td>    <input type="text" placeholder="mm min" />    </td>    <td>    <img id="delete" src="close.png" onclick="changeimage(this)">    </td>    </tr><tr>   <td>   <select id="sele">   <option value="" disabled selected>select option</option>            <option value="sr">sr</option>            <option value="cr">cr</option>            <option value="alm">alm</option>            <option value="incident">incident</option>             <option value="other">other</option>    </select></td>    <td>    <input type="text" placeholder="e.g:1234"/>    </td>    <td>    <input type="text" placeholder="brief work"/>    </td>    <td>    <input type="text" placeholder="mm min" />    </td>    <td>    <img id="delete" src="close.png" onclick="changeimage(this)">    </td>    </tr>    <tr>   <td>   <select id="sele">   <option value="" disabled selected>select option</option>            <option value="sr">sr</option>            <option value="cr">cr</option>            <option value="alm">alm</option>            <option value="incident">incident</option>             <option value="other">other</option>    </select></td>    <td>    <input type="text" placeholder="e.g:1234"/>    </td>    <td>    <input type="text" placeholder="brief work"/>    </td>    <td>    <input type="text" placeholder="mm min" />    </td>    <td>    <img id="delete" src="close.png" onclick="changeimage(this)">    </td>    </tr>    <tr>   <td>   <select id="sele">   <option value="" disabled selected>select option</option>            <option value="sr">sr</option>            <option value="cr">cr</option>            <option value="alm">alm</option>            <option value="incident">incident</option>             <option value="other">other</option>    </select></td>    <td>    <input type="text" placeholder="e.g:1234"/>    </td>    <td>    <input type="text" placeholder="brief work"/>    </td>    <td>    <input type="text" placeholder="mm min" />    </td>    <td>    <img id="delete" src="close.png" onclick="changeimage(this)">    </td>    </tr>    <tr>   <td>   <select id="sele">   <option value="" disabled selected>select option</option>            <option value="sr">sr</option>            <option value="cr">cr</option>            <option value="alm">alm</option>            <option value="incident">incident</option>             <option value="other">other</option>    </select></td>    <td>    <input type="text" placeholder="e.g:1234"/>    </td>    <td>    <input type="text" placeholder="brief work"/>    </td>    <td>    <input type="text" placeholder="mm min" />    </td>    <td>    <img id="delete" src="close.png" onclick="changeimage(this)">    </td>    </tr>    </table>     <input type="button" value="submit" onclick="convert('matrix','taskcount')" />  </form>     </body>    </html> 

action tag in struts.xml

<action name="timesheetprocess" class="com.app.controller.timesheet.timeprocess"     method="execute">     <result name="success">time.jsp</result> </action> 

my action class:

import javax.servlet.http.httpservletrequest; import org.apache.struts2.servletactioncontext;  public class timeprocess {     public string execute() {          httpservletrequest request = servletactioncontext.getrequest();         string tt="tt";         string rf="rf";         string des="des";         string eff="eff";          for(int i=0;i<integer.parseint(request.getparameter("taskcount"));i++)         {             system.out.println("task type :"+ request.getparameter(tt+string.valueof(i)));             system.out.println("task type :"+ request.getparameter(rf+string.valueof(i)));             system.out.println("task type :"+ request.getparameter(des+string.valueof(i)));             system.out.println("task type :"+ request.getparameter(eff+string.valueof(i)));           }         return "success";  } } 

you can control process of parameters population struts2 via overriding interceptors in action config.

<action name="timesheetprocess" class="com.app.controller.timesheet.timeprocess"             method="execute">    <interceptor-ref name="defaultstack">       <param name="params.excludeparams">.*</param>    </interceptor-ref>    <result name="success">time.jsp</result> </action> 

there modify excludeparams property of params interceptor exclude parameters processing via ognl.

you should not exception in way, make sure have configured struts.devmode=false

<constant name="struts.devmode" value="false" /> 

it should remove unnecessary warnings output. if still warnings or exceptions in log, should configure logging framework suppress warnings or errors output.


Comments