当前位置: 代码迷 >> J2EE >> struts2中s:textfield和s:property差别如何就这么大
  详细解决方案

struts2中s:textfield和s:property差别如何就这么大

热度:99   发布时间:2016-04-22 00:22:49.0
struts2中s:textfield和s:property差别怎么就这么大?
jsp从action中读取值显示,s:property就可以显示,但是s:textfield就不能显示!!!

jsp中的代码如下

XML code
    <s:form action="doUpdateScore.action">        <s:hidden name="stu_id" value="%{stu_id}" />        <s:hidden name="course_name" value="%{course_name}" />        <s:property value="%{stuscore.stu_name}"/>        <s:textfield label="姓名" value="%{stuscroe.stu_name}" name="stuscore.stu_name"></s:textfield>        <s:textfield label="分数" value="%{stuscroe.score}" name="stuscore.score"></s:textfield>        <s:text name="%{stuscroe.stu_name}"/>        <s:submit value="提交"></s:submit>    </s:form>



action中代码为

Java code
public class UpdateScoresAction extends ActionSupport {    private ScoresList stuscore;    public ScoresList getStuscore() {        return stuscore;    }    public void setStuscore(ScoresList stuscore) {        this.stuscore = stuscore;    }    private long stu_id;    private String course_name;    public String getCourse_name() {        return course_name;    }    public void setCourse_name(String course_name) {        //this.course_name = course_name;        System.out.println("this is set:" +course_name);        try {            this.course_name = new String(course_name.getBytes("iso-8859-1"),"GBK");        } catch (UnsupportedEncodingException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }    }    private ListScoresService listService;    public ListScoresService getListService() {        return listService;    }    public void setListService(ListScoresService listService) {        this.listService = listService;    }    public long getStu_id() {        return stu_id;    }    public void setStu_id(long stu_id) {        this.stu_id = stu_id;    }    @Override    public String execute() throws Exception {        // TODO Auto-generated method stub        //根据学号和课程号找到一条记录        this.stuscore = this.listService.findstudentscorebycoursename(stu_id, course_name);        System.out.println(stuscore.getCourse_name());        System.out.println(stuscore.toString());        return "success";    }    public String makeUpdate() throws Exception{        if(stuscore == null){            System.out.println("null");        }        else{            System.out.println(stuscore.getCourse_name());        }        this.listService.setStudentScores(stuscore);        return "success";    }}



结果 s:property中有正常的数据(再system.out.println中有输出数据,所有stuScores不是空的),但是s:textfiedl中为空,s:text中也为空!

求助下,大家知道这个是什么问题么?


------解决方案--------------------
theme="simple" 試試
  相关解决方案