在web.xml中写
<filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>*.action</url-pattern>
  </filter-mapping>
在登录页面的form表单里这样写
<s:form action="login/login.action">或者<s:form action="login/login">页面都出错。
但是如果web.xml中这样写
<filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>/*</url-pattern>
  </filter-mapping>
登录页面的form表单里写
<s:form action="login/login">就能正常实现了。
但是我不想改web.xml中过滤器的配置,即只拦截以action结尾的请求,这样form应该肿么写?

解决方案 »

  1.   

    在web.xml中写
    <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>*.action</url-pattern>
      </filter-mapping>
    在登录页面的form表单里这样写
    <s:form action="login.action">在struts.xml中<action name="login" class="......."> 
      

  2.   

    楼主的请求应该是通过jsp页面发起的吧?
    <s:form action="login/login.action">
    页面这样写
    如果你是通过jsp发起请求的话还要在web.xml中
    <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>*.action</url-pattern>
      <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    否则是没有办法进入struts2的过滤器的,所以就会报错。
      

  3.   

    在struts配置文件里面写不就得了,可以配置你想要的后缀,你写*.yourname都可以