日期:2014-05-17 浏览次数:20651 次
<?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>
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