web.xml中
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.ee</url-pattern>
  </servlet-mapping>在jsp中
<html:form action="HelloWorld.o" focus="userName" >
按理说应该运行有问题,但为什么能正常运行呢?
不是应该html:form action 的后缀名和url-pattern设置一致,才可以吗?困惑?

解决方案 »

  1.   

    web.xml
    <web-app>
    <!-- Standard Action Servlet Configuration  -->
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
         <load-on-startup>2</load-on-startup>
      </servlet>  <!-- Standard Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.ee</url-pattern>
      </servlet-mapping>
        
     <!-- The Usual Welcome File List -->
      <welcome-file-list>
        <welcome-file>hello.jsp</welcome-file>
      </welcome-file-list></web-app>hello.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="UTF-8"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>Hello</title>
        <html:base/>
      </head>
      <body bgcolor="white">     Hello
        <html:form action="HelloWorld.w" focus="userName" >
        </html:form>     
      </body>
    </html>
      

  2.   

      mei you chu li
      

  3.   

    你的ActionServlet的有效路径是以.ee结尾的它才处理, 你搞个.o结尾的ActionServlet是不会理你的.!你的项目中没有.o结尾的路径的话就会告诉你找不到路径的的.!
      

  4.   

    难道这样配置运行以后他也可以正常提交表单到你的action?
      

  5.   

    <welcome-file>hello.jsp</welcome-file>
    你的这个hello.jsp是默认的页面,显示是可以的,你提交一下才能看到效果。
      

  6.   


    和你说,不要说 .o,w...就算你action不写 .***后缀都行。ActionServlet都能给你识别出来。
    就是说
    <html:form action="HelloWorld" focus="userName" >  一样可以正确提交到你对应的Action
    这个是ActionServlet保证的。只要你的前缀在config里面找的到就可以了。给不给全名都没所谓。
      

  7.   

    你web.xml里面filter-mapping才是过滤你action的。