去掉页面上面的 ${path} 试试看,或打印${path} 看是什么路径

解决方案 »

  1.   

    ${path}是当前项目的上下文路径,如果要打印出来就是项目名字:struts2/
    就是这样的,去掉它我也试过了,并没有用处
      

  2.   

    看看你的代码发布成功没有,看看classes 目录下面的struts.xml中的配置是否正确,是否有package name="driver" 这一段。
    检查DriverAction 的class文件有没有成功部署到tomcat中
      

  3.   

    这配置文件写的、、、、百度下什么是约定俗成的规范,不能只自己看的懂,还有二楼说的没错,<package name="" extends="struts-default"> 既然没写命名空间,就不要再Action加东西,他默认的就是 namespace="/" ,你action="driverTest"试试
      

  4.   

    规范我知道,可以使用约定插件,也可以使用restfull规范,这里是我写的测试而已
      

  5.   

    <s:form action="/struts2/driverTest"  method="post">
    <s:submit name="submit" value="提交"/>
    </s:form>
    这么写我测试没有问题,你报404,就看一下访问出错的地址呀,是少了个“/'还是什么
      

  6.   

    你的form里的action=“${path}/XXXX”是不是要把那个/去掉呢?
      

  7.   

    我也有类似的问题,求大神帮我看看,我这个更简单也不知道为什么不可以运行。
    这个是web,xml的文件
    <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>
    <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    这个是sturts.xml文件
    <struts> <package name="helloworld" namespace="/" extends="struts-default">

    <!-- 配置一个action,一个struts2请求就是一个action
    name 对应struts2的请求名字(或者对于一个servletPath,但去除/和扩展名),不包含扩展名
    result:结果
     -->
    <action name="product_input">
    <result>/WEB-INF/p1/input.jsp</result>
    </action>
     
    <action name="product_save" class="com.atguigu.struts2.helloworld.Product" method="save">
    <result name="details">/WEB-INF/p1/details.jsp</result>
    </action>

    </package>
    </struts>
      

  8.   

    这个是input.jsp
    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <form action="product_save.action" method="post">
    productName:<input type="text" name="productName"></input>
    <br> <br>
    productDesc:<input type="text" name="productDesc"></input>
    <br> <br>
    productPrice:<input type="text" name="productPrice"></input>
    <br> <br>
    <input type="submit" value="提交"></input>
    <br> <br>
    </form>
    </body>
    </html>
      

  9.   

    在jsp中加入
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
    %>
    <form action="<%=basePath%>/driverTest!xxx.action"  method="post" >xxx表示action中的方法
      

  10.   


    ${path}/driver/driverTest.action
      

  11.   


    楼上哥们正解
    最好不用用你的什么path,这个
    ${context.request.contextPath}/driver/driverTest
      

  12.   

    这不是很明显的问题吗?
    如果你的form用的不是struts2标签,那么你的action就要加后缀,即driverTest.action。
    还可以<s:form action="driverTest" ></s:form>
      

  13.   

    包名最好不要与Action的属性name相同、driver是关键字.
      

  14.   

    namespace 的问题吗?  第二个package namespace="/user"  加上/      1,3package namespace="/"  呢
      

  15.   

    开发struts2下的工程,使用“契约式编程”法则,约定大于配置