Web.xml
xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocationparam-name>
<param-value>
/WEB-INF/classes/applicationContext_service.xml,
/WEB-INF/classes/applicationContext_hibernate.xml
param-value>
context-param>
<resource-ref>
<description>SqlServer Datasource exampledescription>
<res-ref-name>jdbc/StudentManagerres-ref-name>
<res-type>javax.sql.DataSourceres-type>
<res-auth>Containerres-auth>
resource-ref>
<filter>
<filter-name>hibernateFilterfilter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
filter-class>
<init-param>
<param-name>singleSessionparam-name>
<param-value>trueparam-value>
init-param>
filter>
<filter-mapping>
<filter-name>hibernateFilterfilter-name>
<url-pattern>*.dourl-pattern>
filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
listener>
<servlet>
<servlet-name>actionservlet-name>
<servlet-class>org.apache.struts.action.ActionServletservlet-class>
<init-param>
<param-name>configparam-name>
<param-value>/WEB-INF/struts-config.xmlparam-value>
init-param>
<init-param>
<param-name>debugparam-name>
<param-value>3param-value>
init-param>
<init-param>
<param-name>detailparam-name>
<param-value>3param-value>
init-param>
<load-on-startup>0load-on-startup>
servlet>
<servlet-mapping>
<servlet-name>actionservlet-name>
<url-pattern>*.dourl-pattern>
servlet-mapping>
web-app>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocationparam-name>
<param-value>
/WEB-INF/classes/applicationContext_service.xml,
/WEB-INF/classes/applicationContext_hibernate.xml
param-value>
context-param>
<resource-ref>
<description>SqlServer Datasource exampledescription>
<res-ref-name>jdbc/StudentManagerres-ref-name>
<res-type>javax.sql.DataSourceres-type>
<res-auth>Containerres-auth>
resource-ref>
<filter>
<filter-name>hibernateFilterfilter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
filter-class>
<init-param>
<param-name>singleSessionparam-name>
<param-value>trueparam-value>
init-param>
filter>
<filter-mapping>
<filter-name>hibernateFilterfilter-name>
<url-pattern>*.dourl-pattern>
filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
listener>
<servlet>
<servlet-name>actionservlet-name>
<servlet-class>org.apache.struts.action.ActionServletservlet-class>
<init-param>
<param-name>configparam-name>
<param-value>/WEB-INF/struts-config.xmlparam-value>
init-param>
<init-param>
<param-name>debugparam-name>
<param-value>3param-value>
init-param>
<init-param>
<param-name>detailparam-name>
<param-value>3param-value>
init-param>
<load-on-startup>0load-on-startup>
servlet>
<servlet-mapping>
<servlet-name>actionservlet-name>
<url-pattern>*.dourl-pattern>
servlet-mapping>
web-app>
struts-config.xml
xml version="1.0" encoding="UTF-8"?>
DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="people" type="domain.People">form-bean>
form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action path="/savePeople" name="people" type="action.SavePeopleAction">
<forward name="success" path="/listPeople.do">forward>
action>
<action path="/listPeople" name="people" type="action.ListPeopleAction">
<forward name="success" path="/studentList.jsp">forward>
action>
<action path="/deletePeople" name="people" type="action.DeletePeopleAction">
<forward name="success" path="/studentList.jsp">forward>
action>
<action path="/editPeople" name="people" type="action.EditPeopleAction">
<forward name="success" path="/editStudent.jsp">forward>
action>
<action path="/editPeopleDo" name="people" type="action.EditPeopleActionDo">
<forward name="success" path="/studentList.jsp">forward>
action>
<action path="/searchPeople" name="people" type="action.SearchPeopleAction">
<forward name="success" path="/searchList.jsp">forward>
action>
action-mappings>
<controller contentType="text/html;charset=gb2312"
processorClass ="util.Character" />
<message-resources parameter="" />
struts-config>
DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="people" type="domain.People">form-bean>
form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action path="/savePeople" name="people" type="action.SavePeopleAction">
<forward name="success" path="/listPeople.do">forward>
action>
<action path="/listPeople" name="people" type="action.ListPeopleAction">
<forward name="success" path="/studentList.jsp">forward>
action>
<action path="/deletePeople" name="people" type="action.DeletePeopleAction">
<forward name="success" path="/studentList.jsp">forward>
action>
<action path="/editPeople" name="people" type="action.EditPeopleAction">
<forward name="success" path="/editStudent.jsp">forward>
action>
<action path="/editPeopleDo" name="people" type="action.EditPeopleActionDo">
<forward name="success" path="/studentList.jsp">forward>
action>
<action path="/searchPeople" name="people" type="action.SearchPeopleAction">
<forward name="success" path="/searchList.jsp">forward>
action>
action-mappings>
<controller contentType="text/html;charset=gb2312"
processorClass ="util.Character" />
<message-resources parameter="" />
struts-config>
DeletePeopleAction.java
/**/
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.ActionSupport;
import service.StudentManagerImpl;
import domain.People;
/** */ /**
* MyEclipse Struts
* Creation date: 01-17-2007
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class DeletePeopleAction extends ActionSupport ... {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) ...{
Integer id=new Integer(request.getParameter("id"));
StudentManagerImpl manager=(StudentManagerImpl)getWebApplicationContext().getBean("studentManager");
manager.deletePeople(id);
List studentList=manager.listPeople(0,5,"from People");
request.setAttribute("studentList", studentList);
request.setAttribute("currentPage", 1);
return mapping.findForward("success");
}
}
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.ActionSupport;
import service.StudentManagerImpl;
import domain.People;
/** */ /**
* MyEclipse Struts
* Creation date: 01-17-2007
*
* XDoclet definition:
* @struts.action validate="true"
*/
public class DeletePeopleAction extends ActionSupport ... {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) ...{
Integer id=new Integer(request.getParameter("id"));
StudentManagerImpl manager=(StudentManagerImpl)getWebApplicationContext().getBean("studentManager");
manager.deletePeople(id);
List studentList=manager.listPeople(0,5,"from People");
request.setAttribute("studentList", studentList);
request.setAttribute("currentPage", 1);
return mapping.findForward("success");
}
}