日期:2014-05-17  浏览次数:20651 次

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;
    }



    publ