0

问题

我正在使用jsp提交表单和struts 2操作类来处理它。如果有一些问题,那么我会将结果发送到同一页面并显示错误消息。

除了错误消息,我想显示他在提交请求时提供的属性值。

源代码

表单包含很少的文本字段和很少的file类型输入。

我的CreateRequest.jsp文件:

<input type="file" name="attachment" id="myFile1" />
<input type="file" name="attachment" id="myFile2" />
<input type="file" name="attachment" id="myFile3" />
<input type="text" name="operationName" id="operation1" />
<input type="text" name="operationName" id="operation2" />
<input type="text" name="operationName" id="operation3" />

我的动作课:

public class CreateRequest extends ActionSupport {

private List<File> attachment;

private List<String> attachmentContentType;

private List<String> attachmentFileName;


private List<String> operationName

// contains getter and setter for each property

public string execute(){
    // some logic
    //returns error if it fails otherwise success
}
}

struts.xml (Action Servlet) 文件:

<action name="createRequest"
        class="action.CreateRequest">
        <result name="success">RequestStatus.jsp
        </result>
        <result name="input" >CreateRequest.jsp</result>
        <result name="error" >CreateRequest.jsp</result>
 </action>

帮助

CreateRequest.jsp当操作类返回错误时,我如何获取页面中显示的所有这些值。

4

1 回答 1

1

使用ognl value=" %{operationName[0]}"作为文本框

于 2013-10-10T14:04:57.170 回答