ParametersInterceptor error: Unexpected Exception caught, Error setting expression
ParametersInterceptor error: Unexpected Exception caught, Error setting expression
我在包含下拉菜单和隐藏 input
的表单中有一个 table。
JSP
:
<form action="modifyfaculty" method="post">
<table>
<thead class="center">
<tr>
<!-- column names here -->
</tr>
</thead>
<tbody>
<c:forEach var="professor" items="${facultyList}">
<tr>
<!-- more <td> -->
<td align="center">
<c:choose>
<c:when test="${professor.profEmplStatus.equals('FULL')}">
<select name="profEmplStatus" required>
<option value="FULL" selected>FULL</option>
<option value="PART">PART</option>
<option value="RET">RET</option>
<option value="TRMTD">TRMTD</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td align="center">
<c:choose>
<c:when test="${professor.profDept.equals('BSCS-SE')}">
<select name="profDept" required>
<option value="BA-MMA">BA-MMA</option>
<option value="BFDT">BFDT</option>
<option value="BS-AN">BS-AN</option>
<option value="BS-GPD">BS-GPD</option>
<option value="BSBA-FM">BSBA-FM</option>
<option value="BSBA-MKT">BSBA-MKT</option>
<option value="BSCS-SE" selected>BSCS-SE</option>
<option value="BSIT-WD">BSIT-WD</option>
<option value="GENED">GENED</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td class="center">
<input type="hidden" name="profId" value="${professor.profId}" />
<input type="submit" value="Save" />
</td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
ModifyFacultyAction
:
public class ModifyFacultyAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private Integer profId;
private String profEmplStatus;
private String profDept;
@Override
public String execute() {
FacultyManager fm = new FacultyManager();
fm.modifyFaculty("professor_employment_status", profEmplStatus, profId);
fm.modifyFaculty("professor_department", profDept, profId);
return SUCCESS;
}
public Integer getProfId() {
return profId;
}
public void setProfId(Integer profId) {
this.profId = profId;
}
public String getProfEmplStatus() {
return profEmplStatus;
}
public void setProfEmplStatus(String profEmplStatus) {
this.profEmplStatus = profEmplStatus;
}
public String getProfDept() {
return profDept;
}
public void setProfDept(String profDept) {
this.profDept = profDept;
}
}
struts.xml
:
<action name="modifyfaculty" class="com.mypackage.action.ModifyFacultyAction">
<interceptor-ref name="notauth" />
<interceptor-ref name="defaultStack" />
<result type="redirectAction">
<param name="actionName">viewfaculty</param>
</result>
<result name="input" type="redirectAction">
<param name="actionName">viewfaculty</param>
</result>
<result name="index" type="redirect">/index.jsp</result>
</action>
输出:
但是,从下拉列表中选择一个新值并单击 Save
后,我收到一条错误消息。以下是 devMode
日志:
Jan 05, 2015 11:34:43 PM com.opensymphony.xwork2.interceptor.ParametersInterceptor error
SEVERE: Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'profId' on 'class com.mypackage.action.ModifyFacultyAction: Error setting expression 'profId' with value ['100005', '100006', '100007', '100008', '100009', '100010', '100011', ]
Jan 05, 2015 11:34:43 PM com.opensymphony.xwork2.util.LocalizedTextUtil warn
WARNING: Missing key [invalid.fieldvalue.profId] in bundles [[org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]]!
如何解决?
您无需提交 所有 个 table 的 ID。因为您不想将 profId
转换为列表或数组。为每条记录使用单独的表格。
<table>
<thead class="center">
<tr>
<!-- column names here -->
</tr>
</thead>
<tbody>
<c:forEach var="professor" items="${facultyList}">
<tr><td>
<form action="modifyfaculty" method="post">
<table>
<tr>
<!-- more <td> -->
<td align="center">
<c:choose>
<c:when test="${professor.profEmplStatus.equals('FULL')}">
<select name="profEmplStatus" required>
<option value="FULL" selected>FULL</option>
<option value="PART">PART</option>
<option value="RET">RET</option>
<option value="TRMTD">TRMTD</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td align="center">
<c:choose>
<c:when test="${professor.profDept.equals('BSCS-SE')}">
<select name="profDept" required>
<option value="BA-MMA">BA-MMA</option>
<option value="BFDT">BFDT</option>
<option value="BS-AN">BS-AN</option>
<option value="BS-GPD">BS-GPD</option>
<option value="BSBA-FM">BSBA-FM</option>
<option value="BSBA-MKT">BSBA-MKT</option>
<option value="BSCS-SE" selected>BSCS-SE</option>
<option value="BSIT-WD">BSIT-WD</option>
<option value="GENED">GENED</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td class="center">
<input type="hidden" name="profId" value="${professor.profId}" />
<input type="submit" value="Save" />
</td>
</tr>
</table>
</form>
</td></tr>
</c:forEach>
</tbody>
</table>
我在包含下拉菜单和隐藏 input
的表单中有一个 table。
JSP
:
<form action="modifyfaculty" method="post">
<table>
<thead class="center">
<tr>
<!-- column names here -->
</tr>
</thead>
<tbody>
<c:forEach var="professor" items="${facultyList}">
<tr>
<!-- more <td> -->
<td align="center">
<c:choose>
<c:when test="${professor.profEmplStatus.equals('FULL')}">
<select name="profEmplStatus" required>
<option value="FULL" selected>FULL</option>
<option value="PART">PART</option>
<option value="RET">RET</option>
<option value="TRMTD">TRMTD</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td align="center">
<c:choose>
<c:when test="${professor.profDept.equals('BSCS-SE')}">
<select name="profDept" required>
<option value="BA-MMA">BA-MMA</option>
<option value="BFDT">BFDT</option>
<option value="BS-AN">BS-AN</option>
<option value="BS-GPD">BS-GPD</option>
<option value="BSBA-FM">BSBA-FM</option>
<option value="BSBA-MKT">BSBA-MKT</option>
<option value="BSCS-SE" selected>BSCS-SE</option>
<option value="BSIT-WD">BSIT-WD</option>
<option value="GENED">GENED</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td class="center">
<input type="hidden" name="profId" value="${professor.profId}" />
<input type="submit" value="Save" />
</td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
ModifyFacultyAction
:
public class ModifyFacultyAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private Integer profId;
private String profEmplStatus;
private String profDept;
@Override
public String execute() {
FacultyManager fm = new FacultyManager();
fm.modifyFaculty("professor_employment_status", profEmplStatus, profId);
fm.modifyFaculty("professor_department", profDept, profId);
return SUCCESS;
}
public Integer getProfId() {
return profId;
}
public void setProfId(Integer profId) {
this.profId = profId;
}
public String getProfEmplStatus() {
return profEmplStatus;
}
public void setProfEmplStatus(String profEmplStatus) {
this.profEmplStatus = profEmplStatus;
}
public String getProfDept() {
return profDept;
}
public void setProfDept(String profDept) {
this.profDept = profDept;
}
}
struts.xml
:
<action name="modifyfaculty" class="com.mypackage.action.ModifyFacultyAction">
<interceptor-ref name="notauth" />
<interceptor-ref name="defaultStack" />
<result type="redirectAction">
<param name="actionName">viewfaculty</param>
</result>
<result name="input" type="redirectAction">
<param name="actionName">viewfaculty</param>
</result>
<result name="index" type="redirect">/index.jsp</result>
</action>
输出:
但是,从下拉列表中选择一个新值并单击 Save
后,我收到一条错误消息。以下是 devMode
日志:
Jan 05, 2015 11:34:43 PM com.opensymphony.xwork2.interceptor.ParametersInterceptor error
SEVERE: Developer Notification (set struts.devMode to false to disable this message):
Unexpected Exception caught setting 'profId' on 'class com.mypackage.action.ModifyFacultyAction: Error setting expression 'profId' with value ['100005', '100006', '100007', '100008', '100009', '100010', '100011', ]
Jan 05, 2015 11:34:43 PM com.opensymphony.xwork2.util.LocalizedTextUtil warn
WARNING: Missing key [invalid.fieldvalue.profId] in bundles [[org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]]!
如何解决?
您无需提交 所有 个 table 的 ID。因为您不想将 profId
转换为列表或数组。为每条记录使用单独的表格。
<table>
<thead class="center">
<tr>
<!-- column names here -->
</tr>
</thead>
<tbody>
<c:forEach var="professor" items="${facultyList}">
<tr><td>
<form action="modifyfaculty" method="post">
<table>
<tr>
<!-- more <td> -->
<td align="center">
<c:choose>
<c:when test="${professor.profEmplStatus.equals('FULL')}">
<select name="profEmplStatus" required>
<option value="FULL" selected>FULL</option>
<option value="PART">PART</option>
<option value="RET">RET</option>
<option value="TRMTD">TRMTD</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td align="center">
<c:choose>
<c:when test="${professor.profDept.equals('BSCS-SE')}">
<select name="profDept" required>
<option value="BA-MMA">BA-MMA</option>
<option value="BFDT">BFDT</option>
<option value="BS-AN">BS-AN</option>
<option value="BS-GPD">BS-GPD</option>
<option value="BSBA-FM">BSBA-FM</option>
<option value="BSBA-MKT">BSBA-MKT</option>
<option value="BSCS-SE" selected>BSCS-SE</option>
<option value="BSIT-WD">BSIT-WD</option>
<option value="GENED">GENED</option>
</select>
</c:when>
<!-- more <c:when> blocks -->
</c:choose>
</td>
<td class="center">
<input type="hidden" name="profId" value="${professor.profId}" />
<input type="submit" value="Save" />
</td>
</tr>
</table>
</form>
</td></tr>
</c:forEach>
</tbody>
</table>