0

管理页面.jsp

我正在从地图中迭代用户列表并在 UI 中显示它。尝试发送用户为 agRestricted 选择的 Yes/No 值并在批准操作中处理它。

 <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

}

注册表格.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;
        }
}

管理页面.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>
4

0 回答 0