67,512
社区成员
发帖
与我相关
我的任务
分享
<bean name="/employee" class="com.petclinic.struts.action.EmployeeAction">
<property name="employeeService">
<ref bean="employeeService" />
</property>
</bean>
<action parameter="method" path="/employee" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="list" path="/pages/sysManage/employee.jsp" />
</action>
public ActionForward listEmployee(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
List listEmployee=employeeService.findAllEmployee();
System.out.println("listEmployee---->"+listEmployee);
request.setAttribute("listEmployee", listEmployee);
return mapping.findForward("list");
}
<html:link action="employee.do?method=listEmployee " target="mainFrame" styleClass="left-font03" onclick="list('5');">系统管理</html:link>
添加spring和hibernate有顺序问题
先加spring
修改web.xml
配置的是上下文参数
<context-param>
<param-name>contextConfigLocation</param-name>名称是固定的,一定要记下来
<param-value>classpath*:applicationContext*.xml</param-value>加载classes下面的所有以applicationContext开头的xml文件
</context-param>
加载上下文参数的监听器
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
两个过滤器,转码(CharacterEncodingFilter)和延迟加载(OpenSessionInViewFilter)
修改struts-config.xml
使用Spring的请求处理器
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>
修改applicationContext.xml,将Action交由spring管理
其中bean的一定要使用name属性进行声明,因为id不能接受/这个符号
name属性的值和struts-config.xml中action配置的path路径一致。
<bean name="/student"
class="org.totong.struts.action.StudentAction">
<property name="studentService" ref="studentService"></property>
</bean>