struts2的注册方法发出
空指针这是struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- struts报错的友好提示 -->
<constant name="struts.devMode" value="true"/>
<!-- 统一修改struts表单标签中的样式 -->
<constant name="struts.ui.theme" value="simple"></constant>
<!-- 指定action由spring来创建 -->
<constant name="struts.objectFactory" value="spring"></constant>
<package name="default" namespace="/" extends="struts-default">
<action name="employee_*" class="employeeAction" method="{1}">
<result name="loginUI">/login.jsp</result>
</action>
</package>
</struts>
employee-beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
">
<!-- 配置action -->
<bean id="employeeAction" class="cn.itcast.action.EmployeeAction" scope="prototype"></bean>
<!-- 配置EmployeeDao -->
<bean id="employeeDao" class="cn.itcast.dao.EmployeeDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 配置EmployeeService -->
<bean id="employeeService" class="cn.itcast.service.EmployeeService">
<property name="employeeDao" ref="employeeDao"></property>
</bean>
</beans>
Action的注册方法
public class EmployeeAction extends ActionSupport implements ModelDriven<Employee> {
//创建模型驱动,收集客户端的参数
Employee model = new Employee();
public Employee getModel() {
return model;
}
//引入service
private IEmployeeService employeeService;
//xml方式所提供的set()方法
public void setIemployeeService(IEm