我点击一个url=/list?type=1的连接
结果地址栏出现了/list/?type=1,同时错误:Struts has detected an unhandled exception: Messages: There is no Action mapped for namespace / and action name list/. 
 
我的action的名字是 list 怎么就出现了 list/ 呢?如果我把url改成 /list.action?type=1 也就是说不省略 .action 就不会有问题
这是为什么呢?补充一下,我是想做在一个页面里有多个选项卡哪种类型的连接,通过指定type来取得页面

解决方案 »

  1.   

    因为你Struts配置路径的时候配置的是*.action所以只用list.action这个链接才能匹配上Struts
      

  2.   

    你用的是struts几
    如果时struts2的话路径后可以不加.action其默认的就是.action如果是struts1.X的话路径后就要加上你配的后缀名了
      

  3.   

    首先要看你是不是用的struts标签,是struts1.x还是struts2.x,如果用的普通标签就得加上后缀
    1.x的话一般是以.do,在2.x中默认是.action,如果用到了struts1.x的标签库也是.do,如果用到了struts2.x的话,就可以省略后缀了。
      

  4.   

    是我的问题没说清楚吗?
    我不是问能不能省略后缀
    后面的人的思路都被三四楼的回答带走了
    我用的是struts2.1.6
    jsp页面中的一个连接:<s:a href="list.action?type=1">list1</s:a><br/>
    struts.xml里面有一个叫 list 的action,连接result是 /list/list1.jsp,即根目录下的list文件夹下的list1.jsp
    点击连接是可以的,但改成<s:a href="list?type=1">list1</s:a><br/> 就是把.action省略就不行了,这是为什么?
    url显示的是: 项目名/list/?type=1
    给出的错误是:
    Stacktraces
    There is no Action mapped for namespace / and action name list/. - [unknown location] 
      

  5.   

    我的其他的action是可以省略.action的
      

  6.   

    <s:a href="list?type=1">
    改成
    <s:a href="{base}/list?type=1">
      

  7.   

    或者定义base标签
    <base href="http://localhost:8080/project/" />http://localhost:8080/project/改成你的项目的绝对地址。