问题:HTTP Status 404 - There is no Action mapped for namespace /department and action name departmentAction.
用的struts2+hibernate3+spring2.5
测试过了, spring+hibernate已经集成, 就struts2这儿有问题 ,改了很久都不知道为啥???
配置文件:
src/struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.ui.theme" value="simple"/>
<package name="depart" namespace="/department" extends="struts-default">
<action name="list" class="departmentAction">
<result name="list">/WEB-INF/page/department/departmentlist.jsp</result>
</action>
</package>
</struts>
DepartmentAction:采用@Controler注解,让spring管理action
@Controller
public class DepartmentAction {
public String execute(){
ActionContext.getContext().put("message","asfaf");
return "list";
}
}
在地址栏输入 http://localhost:8080/struts2/department/departmentAction.action
就是404 ,想了半天不知道怎么回事。。 求解
------解决方案--------------------------------------------------------
web.xml呢?
------解决方案--------------------------------------------------------
There is no Action mapped for namespace /department and action name departmentAction.
没有找到 /department
------解决方案--------------------------------------------------------
你是不是应该访问“http://localhost:8080/struts2/department/list.action”
而不是“http://localhost:8080/struts2/department/departmentAction.action”
因为你配置的action的name是list
------解决方案--------------------------------------------------------