<html:select>在<logic:iterate>中使用是/否选项,将null传递给struts中的表单

时间:2018-10-10 13:22:40

标签: struts actionform

adminpage.jsp

我正在从地图上迭代用户列表,并将其显示在UI中。尝试发送用户为agRestricted选择的是/否值,并在批准操作中对其进行处理。

 <logic:iterate name="usersDetails" id="user" indexId="index">    
    <td><bean:write name="user" property="agName" /></td>
    <td>
    <html:select property="agRestricted" name="user">
      <html:option value="Yes">Yes </html:option>
      <html:option value="No">No</html:option>
    </html:select>
    </td>
    <td>
    <html:button property="Approve" value="" title="Approve" onclick="adminApprove()"></html:button>
    </td>
    </logic:iterate> 

ApproveAction.java

在批准操作中,我试图读取提交时以表格形式发送的agRestricted值。但是我在这里变得空了。我做错什么了吗?

    public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                HttpServletResponse response) throws Exception {
    RegistrationForm registrationForm = (RegistrationForm) form;
    if (loggingService.isInfoEnabled()) {
                loggingService.logInfo(this, "is AG Restricted", agRestricted);
            } // if{}//printing null

}

RegistrationForm.java

POJO用于​​设置表单变量的类。

 public class RegistrationForm extends org.apache.struts.action.ActionForm {
    private String agRestricted;
        private String agName;
    public String getAgRestricted() {
            return agRestricted;
        }
        public void setAgRestricted(String agRestricted) {
            if (loggingService.isInfoEnabled()) {
                loggingService.logInfo(this, "is AG Restricted", agRestricted);
            } // if{}//printing null
            this.agRestricted = agRestricted;
        }
        public String getAgName() {
            return agName;
        }
        public void setAName(String agName) {
            this.agName = agName;
        }
}

adminpage.js

function adminApprove() {

var newUrl2 = './adminpage.do';
document.forms[0].action = newUrl2;
        document.forms[0].submit(); 

    }

struts-config.xml

<action input="/adminApprove" name="RegistrationForm"
            path="/adminpage" scope="request"
            type="com.cts.assetserv.core.web.action.ApproveAction" parameter="method">
            <forward name="Success" path="/adminpage.do" />
            <forward name="Error" path="/adminpage.do" />
        </action>

0 个答案:

没有答案