java后台接收数据

1、getParameter来获取数据

int userId = Integer.parseInt(this.getgetParameter().getParameter("userId"));
        int tieId = Integer.parseInt(this.getRequest().getParameter("tieId"));

2、java前台–》后台的接收:JSP中直接用属性名称来提交数据:
///后台

@Component(value="tanWeiAction")
public class TanWeiAction extends BaseAction{
    private Ttanwei tanwei;

    public Ttanwei getTanwei() {
        return tanwei;
    }
    public void setTanwei(Ttanwei tanwei) {
        this.tanwei = tanwei;
    }
/**
     * 添加摊位
     */
    public void addTanWei(){
        tanwei.setIsValid(true);
        tanwei.setBeiZhu("");
        tanwei.setCatagoryId(0);
        tanwei.setImgUrl("");
        tanwei.setTanWeiName("");

        int result=this.tanWeiService.addTanWei(tanwei);

        if(result>0){
            MSG="OK";
        }else{
            MSG="NO";
        }
        this.writeJson(MSG);
    }

/前台:

<form id="tanWeiform" method="post" style="margin:0 auto;">
                <input id="tanweiId" name="tanwei.id" type="hidden" /> <input
                    id="imgUrl" name="tanwei.imgUrl" type="hidden" />
                <table style="margin:0 auto">
                    <tr>
                        <th>商品类别:</th>
                        <td><input name="tanwei.catagoryId" id="catagoryTree"
                            class="easyui-combotree" data-options="required:true">
                        </td>
                    </tr>
                    <tr>
                        <th>摊位名称:</th>
                        <td><input name="tanwei.tanWeiName" id="rname"
                            class="easyui-validatebox" data-options="required:true">
                        </td>
                    </tr>

                </table>
            </form>

3、使用实体类来接收:APP前台发送数据
/字段名要一致!

Tsignature ts = new Tsignature();
        ts.setIsValid(true);
        ts.setSignatrue(encodingFunction.getMethodEncoding(user.getSignature()));
        ts.setUserId(user.getId());
        int i = this.userService.addUserSignature(ts);

实现:ModelDriven

@Component(value = "userAction")
public class UserAction extends BaseAction implements ModelDriven<User> {

    private User user = new User();
    @Override
    public User getModel() {
        return user;
    }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值