在学习struts时候,出现There is no Action mapped for action name Category_list.找了半天都没找出来问题,请大家帮忙解决下啊,谢谢。
我在浏览器里面敲的:http://localhost:8080/BBS/admin/CategoryList.struts.xml放在src路径下,文件如下
<?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>
<package name="admin" extends="struts-default" namespace="/admin">
<action name="Category_list" class="com.rh.bbs.action.CategoryAction" method="list">
<result>/admin/Category_list.jsp</result>
</action>
</package>
</struts>com.rh.bbs.action.CategoryAction内容如下:
package com.rh.bbs.action;import java.util.List;import com.opensymphony.xwork2.ActionSupport;
import com.rh.bbs.model.Category;public class CategoryAction extends ActionSupport{
public List<Category> categories;
public String list(){
return SUCCESS;
}
}
WebRoot下面有:admin文件夹,Category_list.jsp包含在里面。
请大家帮忙解答下。
  

解决方案 »

  1.   

    http://localhost:8080/BBS/admin/CategoryList --> http://localhost:8080/BBS/admin/Category_list
      

  2.   

    <result>/admin/Category_list.jsp</result>
    楼上正解
      

  3.   

    哦,这个是我写错了,我敲的是Category_list。呵呵,改来改去所有贴上来的时候错了。不是这个问题,呵呵
      

  4.   


    配置文件倒是没什么问题那你的文件到底编译了嘛?  部署了嘛?重启了嘛?你重新编译整个项目然后部署..看看 classes目录中的struts.xml 文件和你当前的内容是否一致?然后关闭所有浏览器窗口清空缓存 再运行
      

  5.   

    报这个错误,很明显action找不着,你的访问路径和配置文件正确,那么你是否在web.xml中配置了拦截。。
      

  6.   

    是否有struts.properties文件?或者在struts.xml中加上<constant .../>,我第一次用struts2也是这个问题,在struts.xml中加上    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
        <constant name="struts.devMode" value="true" />就好了
      

  7.   

    我加了还是不行哦,struts.enable.DynamicMethodInvocation这个属性是在动态方法调用时候才起作用的,而struts.devMode这个是修改后它不用再重新启动用的。呵呵,我感觉很怪异。以前没遇到这个问题。
    下面是我的web.xml文件<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      
      <filter>
       <filter-name>struts2</filter-name>
       <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
      </filter>
      
      <filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
    </web-app>
    帮忙看看啊
      

  8.   

    我到文件路径下面去看了,classes里面类都变异了,而且struts.xml文件也一致。
      

  9.   

    可能是命名空间的问题,
    http://localhost:8080/BBS/admin/admin/Category_list
    你这样访问试试
      

  10.   

    这样也不行哦,我感到很诧异,我配置另外一个package,namespace="/",然后下面配置action,敲入http://localhost:8080/BBS/Category,这样它也会报同样的错误,感觉struts.xml没有响应一样,我在web.xml中夜配置了filter啊,请问怎么回事啊?好郁闷
      

  11.   

    测试一下环境到底搭好没有. 写个namespace为/的试一下
      

  12.   

    写namespace为/也不行,不知道为什么啊
      

  13.   

    很明显你的配置文件里面的名字和你的url里面的action不相同
      

  14.   

    告诉大家我的错误,不要鄙视我啊,我把struts.xml写成了strutsl.xml,我没注意,因为他上面显示一个struts的标准的图标(一个齿轮形状)。唉
      

  15.   

    struts.xml放的位置和web.xml中配置的路径不匹配