在URL访问...*.action的时候,如果想去掉后面的.action也能访问 该如何实现
希望各位 能人,高手指点迷津,非常感谢!!!!

解决方案 »

  1.   

    这个我也想知道.
      在web.xml中可以配置请求的后缀名,你试试能不能设置为空呢
      

  2.   

    URL 中 输入 http://localhost:8080/工程名/a.action 能访问
    现在 我想实现 http://localhost:8080/工程名/a 也能访问
    这样说能明白么?
      

  3.   

    web.xml 中 配置的是 
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    是这样的
      

  4.   

    struts2标签
    <s:form默认就不需要写action
      

  5.   

    可能会影响安全性。http://zddava.javaeye.com/blog/215504
      

  6.   


    <filter>
            <filter-name>struts2 </filter-name>
            <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2 </filter-name>
            <url-pattern>/*.action </url-pattern>
        </filter-mapping> 
      

  7.   

    struts2.0的form表单提交时,不需要写action!在web.xml中配置一下就可以!
      

  8.   

    使用struts2默认后缀名,struts2默认配置struts.action.extension=action,,。 
    即action或者不写。 
    http://localhost:8080/xxx/login 
    和 
    http://localhost:8080/xxx/login.action 都能正常访问。
      

  9.   

    在form表单中可以省略,如果想着url中省略action 应该不行吧。不然怎么知道你请求的url是不是
    Struts action咧。
      

  10.   

    在web.xml中配置两个mapping,一个对于"*.action",一个对应"/*"
      

  11.   

    convention应该说是解决了这个问题。它认为所有的url都是去请求一个action,如果没有action 就会取请求相应的JSP。
      

  12.   

    convention 恩 不知道可以不 但是我这个项目里面要求不用jsp 全部页面都是HTML
    #12 那位仁兄和后面几位都说 那办法可行 我试了好多次 行不通
    在struts2中实现去掉后缀及url重写 
    一个是SmartUrls(Struts2的插件,下载地址:http://code.google.com/p/smarturls-s2/downloads/list) 还有就是urlrewritefilter(下载地址:http://tuckey.org/urlrewrite/dist/urlrewritefilter-2.6.zip)
    昨天 在网上找的资料 现在仍然在实验中...
      

  13.   

    struts2.0的form表单提交时,不需要写action!在web.xml中配置一下就可以!<filter>
            <filter-name>struts2 </filter-name>
            <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2 </filter-name>
            <url-pattern>/*.action</url-pattern> --去掉.action
        </filter-mapping> 
      

  14.   

    设置:struts2默认配置struts.action.extension=
    看看,没测试过,感觉怎么也应该设置一个后缀,不能像serverlet那样直接定义路径
      

  15.   

    #21-23 已证实 在struts2.0 是不行 
    网上有人说 2.1 可以像#23那样做 没有测试过