当我尝试添加在 CustomerAction
类中定义的不同方法时,系统输入该方法,但执行该方法后,Struts 无法检测到类 bean 名称:
Invalid action class configuration that references an unknown class named [customerActionBean]
struts.xml
:
<constant name="struts.devMode" value="false" />
<package name="myPack" extends="struts-default">
<action name="customerAction" class="customerActionBean">
<result name="successView">/success.jsp</result>
</action>
<action name="welcome" class="customerActionBean" method="welcome">
<result name="successView">/index2.jsp</result>
</action>
</package>
Action 类别:
public String execute() throws Exception {
customerService.addCustomer(customer);
savedCustomerList=customerService.getCustomers();
return "successView";
}
public String welcome(){
System.out.println("girdiiiiiii");
savedCustomerList=customerService.getCustomers();
return "succesView";
}
应用程序上下文:
<bean id="customerActionBean" class="com.thecafetechno.CustomerAction" >
<property name="customerService" ref="CustomerService" />
</bean>
最佳答案
我遇到了同样的异常,只需将 struts2-spring-plugin-2.3.16.1.jar 包含到构建路径中就解决了我的问题。
关于java - Struts 2 Spring 3 集成,未找到操作类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19082083/