当前位置: 代码迷 >> Java Web开发 >> Struts2.3+Spring3.2+hibernate4.2 Could not find action or result,该怎么处理
  详细解决方案

Struts2.3+Spring3.2+hibernate4.2 Could not find action or result,该怎么处理

热度:697   发布时间:2016-04-12 22:46:44.0
Struts2.3+Spring3.2+hibernate4.2 Could not find action or result
Struts.xml中第二个package的action可以运行,但第一个package中的action运行总是报错:
There is no Action mapped for namespace [/control/center] and action name [main] associated with context path [/babasport]. - [unknown location]

请各位老师指点指点
下面是源码

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.i18n.encoding" value="UTF-8" /> 
<constant value="true" name="struts.devMode" /> 
<package name="controlmain" namespace="/control/center" extends="struts-default">
<action name="/main" class="productType">
<result>/WEB-INF/page/controlcenter/default.jsp</result>
</action>
<action name="/top" class="productType" method="top">
<result name="top" >/WEB-INF/page/controlcenter/top.jsp</result>
</action>
<action name="/left" class="productType" method="left">
<result name="left" >/WEB-INF/page/controlcenter/menu.jsp</result>
</action>
<action name="/right" class="productType" method="right">
<result name="right" >/WEB-INF/page/controlcenter/right.jsp</result>
</action>
<action name="/end" class="productType" method="end">
<result name="end" >/WEB-INF/page/controlcenter/end.jsp</result>
</action>
</package> 

<package name="producttype" namespace="/" extends="struts-default"><!--
   name="productType"用于找action类上@Conponent("productType")的类  
--><action name="productTypeList" class="productType" method="listProType">
<result name="list">/WEB-INF/page/product/productList.jsp</result>
</action>
</package> 

</struts>


action文件:
@Component("productType")
public class ProductTypeAction extends ActionSupport{
private List<ProductType> type;
private ProductTypeManage typeManage;
public ProductTypeManage getProductTypeManage() {
return typeManage;
}
public List<ProductType> getType() {
return type;
}
public String listProType() throws Exception{
type = typeManage.find(1);
return "list";
}
@Resource(name="productTypeManageImpl")
public void setProductTypeManage(ProductTypeManage productTypeManage) {
this.typeManage = productTypeManage;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
public String left() throws Exception{
return "left";
}
public String right() throws Exception{
return "right";
}
public String end() throws Exception{
return "end";
}
public String top() throws Exception{
return "top";
}
public void setType(List<ProductType> type) {
this.type = type;
}
}
  相关解决方案