日期:2014-05-19 浏览次数:20682 次
<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>
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"; } }