设为首页 加入收藏

TOP

Struts2 Jsp 动态明细向后台传值(一)
2019-09-17 16:28:39 】 浏览:40
Tags:Struts2 Jsp 动态 明细 后台

最近培训新人,最后练习使用Struts2框架练习,但是联系中碰到了画面List对象传后台无法传递的问题。网上看了一圈没有找到对应的解决办法。最后自己找到了一种,写下来后面可以再看。

注:方法千千万,有其他能解决的,或者我写的有不对的地方欢迎指正!

上图表格里面的就是我想上传到后台的内容,因为下面的更新按钮,删除按钮想要多条操作,所以最省心的办法就是整表提交(当然也有通过js把选中的对象拼成字符串再传到后台分割,但是太low了。。。)

解决办法:

两个javaBean:ResultBean 和 ResultDetailBean(ResultDetailBean嵌套在ResultBean中)

ResultBean代码:

package Bean;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class ResultBean {
    private String stuId = "";
    private String stuName = "";
    private String classes = "";
    private BigDecimal grade;
    private String sex = "";
    private String detailSize = "";
    //ResultDetailBean的get set方法
    private List<ResultDetailBean> detailList = new ArrayList<ResultDetailBean>();

    /**
     * @return the stuId
     */
    public String getStuId() {
        return stuId;
    }

    /**
     * @param stuId
     *            the stuId to set
     */
    public void setStuId(String stuId) {
        this.stuId = stuId;
    }

    /**
     * @return the stuName
     */
    public String getStuName() {
        return stuName;
    }

    /**
     * @param stuName
     *            the stuName to set
     */
    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    /**
     * @return the classes
     */
    public String getClasses() {
        return classes;
    }

    /**
     * @param classes
     *            the classes to set
     */
    public void setClasses(String classes) {
        this.classes = classes;
    }

    /**
     * @return the grade
     */
    public BigDecimal getGrade() {
        return grade;
    }

    /**
     * @param grade
     *            the grade to set
     */
    public void setGrade(BigDecimal grade) {
        this.grade = grade;
    }

    /**
     * @return the sex
     */
    public String getSex() {
        return sex;
    }

    /**
     * @param sex
     *            the sex to set
     */
    public void setSex(String sex) {
        this.sex = sex;
    }

    public List<ResultDetailBean> getDetailList() {
        return detailList;
    }

    public void setDetailList(List<ResultDetailBean> detailList) {
        this.detailList = detailList;
    }

    public String getDetailSize() {
        return detailSize;
    }

    public void setDetailSize(String detailSize) {
        this.detailSize = detailSize;
    }
}

ResultDetailBean的代码:

package Bean;

public class ResultDetailBean {
    private String no = "";
    private String sel = "0";
    private String curId = "";
    private String curName = "";
    private String score = "";

    /**
     * @return the no
     */
    public String getNo() {
        return no;
    }

    /**
     * @param no
     *            the no to set
     */
    public void setNo(String no) {
        this.no = no;
    }

    /**
     * @return the sel
     */
    public String getSel() {
        return sel;
    }

    /**
     * @param sel
     *            the sel to set
     */
    public void setSel(String sel) {
        this.sel = sel;
    }

    /**
     * @return the curId
     */
    public String getCurId() {
        return curId;
    }

    /**
     * @param curId
     *            the curId to set
     */
    public void setCurId(String curId) {
        this.curId = curId;
    }

    /**
     * @return the curName
     */
    public String getCurName() {
        return curName;
    }

    /**
     * @param curName
     *            the curName to set
     */
    public void setCurName(String curName) {
        this.curName = curName;
    }

    /**
     * @return the score
     */
    public String getScore() {
        return score;
    }

    /**
     * @param score
     *            the score to set
     */
    public void setScore(String score) {
        this.score = score;
    }
}

JavaBean已经定

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇java 1.8新特性 lambda表达式 - s.. 下一篇thymeleaf各种问题,标签没用?网..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目