java.lang.NoSuchMethodException: Action[/employee] does not contain specified me
Spring 配置文件
<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>
[解决办法]
我估计是
你的JSP页面是存在于另一个目录下
当你处理完一个请求后跳转到当前页面
然后再请求action时路径变成了HTTP://localhost:8080/XXX/文件所在目录名/employee.do?method=listEmployee
而正确的路径HTTP://localhost:8080/XXX/文件所在目录名/employee.do?method=listEmployee
无红色部分