当前位置: 代码迷 >> Java Web开发 >> Struts2.2.3.1,Method "setStudent" failed for object com.city.action.UpdateAction解决方法
  详细解决方案

Struts2.2.3.1,Method "setStudent" failed for object com.city.action.UpdateAction解决方法

热度:570   发布时间:2016-04-17 11:12:10.0
Struts2.2.3.1,Method "setStudent" failed for object com.city.action.UpdateAction
在自学struts2 就自己写了个小的管理程序
在对信息进行修改的时候出错了,请大家帮帮忙
struts.xml
XML code
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"    "http://struts.apache.org/dtds/struts-2.0.dtd"><struts>    <constant name="struts.enable.DynamicMethodInvocation" value="true" />    <constant name="struts.devMode" value="false" />    <package name="default" namespace="/" extends="struts-default">        <default-action-ref name="index" />                <action name="index" class="com.city.action.StudentAction">            <result name="success">/index.jsp</result>            <result name="update">/update.jsp</result>            <result name="add">/add.jsp</result>            <result name="goback" type="redirectAction">                    <param name="actionName">back</param>                <param name="namespace">/</param>            </result>        </action>        <action name="back" class="com.city.action.StudentAction">            <result name="success">            /index.jsp            </result>        </action>        <action name="add" class="com.city.action.AddAction">            <result name="goback" type="redirectAction">                    <param name="actionName">back</param>                <param name="namespace">/</param>            </result>        </action>        <action name="update" class="com.city.action.UpdateAction">            <result name="goback" type="redirectAction">                    <param name="actionName">back</param>                <param name="namespace">/</param>            </result>            <result name="input">            /error.jsp            </result>        </action>    </package>       <!-- Add packages here --></struts>


StudentAction
Java code
package com.city.action;import java.util.ArrayList;import java.util.List;import java.util.Map;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.apache.struts2.ServletActionContext;import org.apache.struts2.interceptor.RequestAware;import org.apache.struts2.interceptor.ServletRequestAware;import com.opensymphony.xwork2.Action;import com.opensymphony.xwork2.ActionSupport;import com.city.model.*;import com.city.server.StudentServer;public class StudentAction extends ActionSupport{        List<Student> list = new ArrayList<Student>();    HttpServletRequest request=ServletActionContext.getRequest();    private String id;    private Student student = new Student();        public HttpServletRequest getRequest() {        return request;    }    public void setRequest(HttpServletRequest request) {        this.request = request;    }    public Student getStudent() {        return student;    }    public void setStudent(Student student) {        this.student = student;    }    public List<Student> getList() {        return list;    }    public void setList(List<Student> list) {        this.list = list;    }//    public void setServletRequest(HttpServletRequest request){//        this.request = request;//    }    public String execute(){        list = new StudentServer().checkStuList();        return SUCCESS;    }        public String gotoUpdate(){        this.student = new StudentServer().checkStuById(Integer.parseInt(id));        return "update";    }        public String gotoAdd(){            return "add";    }    public String deleteStuById(){        new StudentServer().deleteStu(Integer.parseInt(id));        return "goback";    }        public void setId(String id) {        this.id = id;    }    public String getId() {        return id;    }}
  相关解决方案