struts中submit标签传递参数问题

<div align="center">
    <s:submit value="删除" class="searchbutton" method="deleteAuthByEmpId"/>
    <input type="hidden" name="empAuthId" value=<s:property value="#authorization.empId"/>_<s:property value="#authorization.authId"/>
    >

</div>

传递的数值是全部的



这样却可以获取单条的数值
<div align="center">
    <input type="submit" value="编辑" name="delete"  class="input2"/>
    <input type="hidden" name="flag"
           value=<s:property value="#employee.number"></s:property>
    />
</div>


注意:不能使用两个hidden


终极结局方案,使用超链接
jsp中:
<div align="center">
    <%--
    <s:submit value="删除" class="searchbutton" method="deleteAuthByEmpId">
    <input type="hidden" name="empAuthId" value=<s:property value="#authorization.empId"/>_<s:property value="#authorization.authId"/>
    >
    </s:submit>
    --%>
    <a href="deleteAuthByEmpId.action?empAuthId=<s:property value="#authorization.empId"/>_<s:property value="#authorization.authId"/>">
        <input type="button" value="删除" class="searchbutton">
    </a>
</div>

struts中配置:
<action name="deleteAuthByEmpId" class="im.acs.action.GateAction" method="deleteAuthByEmpId">
    <result name="success" type="redirect">queryAuthorizationAll</result>
</action>

action中:

/*
* 删除授权
* */
public String deleteAuthByEmpId(){
    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>deleteAuth>>>>>>>>>>>>>>>>>>>>>");

    String[] empAuthArray = empAuthId.split("_");
    int employeeId = Integer.parseInt(empAuthArray[0]);
    int authId = Integer.parseInt(empAuthArray[1]);

    List<Authorization> authList = gateService.findAuthByEmpId(employeeId);
    //此empId已授权且只有一条,更新此条记录
    if(authList.size() == 1 && authList.get(0).getFlag() == 1){

        Authorization auth = new Authorization();
        auth.setId(authList.get(0).getId());
        auth.setFlag(0);
        auth.setGateId(1);
        auth.setEmployeeId(employeeId);
        auth.setIdentificationId(authList.get(0).getIdentificationId());
        //update
        gateService.updateAuth(auth);
    }//授权信息多条
    else if(authList.size() >= 2){
        //delete
        gateService.deleteAuthByAuthId(authId);
    }

    return SUCCESS;
}









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值