gpt4 book ai didi

java - 参数拦截器错误: Unexpected Exception caught,设置表达式错误

转载 作者:太空宇宙 更新时间:2023-11-04 06:18:19 26 4
gpt4 key购买 nike

我的表单中有一个表格,其中包含下拉列表和隐藏的输入

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>

输出: enter image description here

但是,从下拉列表中选择新值并单击保存后,我收到错误。以下是 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]]!

如何解决这个问题?

最佳答案

您无需提交表的所有 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>

关于java - 参数拦截器错误: Unexpected Exception caught,设置表达式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27778644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com