本帖最后由 scjtswj 于 2013-11-14 10:13:48 编辑

解决方案 »

  1.   

    提交到action的时候命名空间的错误、。
      

  2.   

    namespace="/"
      

  3.   

     namespace="/" 这样改后,还是
    HTTP Status 404 - There is no Action mapped for namespace [/] and action name [userLogin] associated with context path [].
    这个错误
      

  4.   

    你改成空或者给他一个命名。然后再form标签里的时候加上命名空间。
      

  5.   

    <s:form action="action" namespace="/命名">
      

  6.   

    namespace="/demo"  jsp文件:
    <s:form action="userLogin" namespace="/demo"> tomcat里有个警告:
    怎么感觉配置修改了没起作用? 我重启过tomcat了看了下生成的Html里是这样的:
    <form method="post" action="userLogin" name="userLogin" id="userLogin">
    提交到的url是 http://localhost/userLogin,还是报错:
    HTTP Status 404 - There is no Action mapped for namespace [/] and action name [userLogin] associated with context path [].不用<s:form>标签,用<form action="/demo/userLogin.action" method="post">
    提交到的url是 http://localhost/demo/userLogin.action,报错信息:
    HTTP Status 404 - There is no Action mapped for action name userLogin.
      

  7.   


    当然你可以参考下我这个免费项目实例,里面也用到struts,相信对你的帮助还是有的http://blog.csdn.net/shadowsick/article/details/8903278
      

  8.   

    <package name="struts2" namespace="" extends="struts-default">命名了吗?
      

  9.   


    <?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE struts PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
          "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
        <package name="struts2" extends="struts-default">
            <global-results>
                <result name="login" type="redirect">/login.jsp</result>
            </global-results>
            <action name="userLogin" class="hs.homs.action.UserLoginAction">
                <result name="success" type="redirect">/entrust.action</result>
                <result name="error">/login.jsp</result>
            </action>
            <action name="entrust" class="hs.homs.action.EntrustAction">
                <result name="success">main.jsp</result>
                <result name="add">main.jsp</result>
            </action>
            <action name="entrust_add" method="add" class="hs.homs.action.EntrustAction">
                <result name="success">main.jsp</result>
            </action>
        </package>
    </struts>
      

  10.   


    用这个配置?
    我换成这个配置了打开http://localhost/login.jsp的时候,tomcat就有警告了:
    死活说找不到userLogin这个action
      

  11.   


    用这个配置?
    我换成这个配置了打开http://localhost/login.jsp的时候,tomcat就有警告了:
    死活说找不到userLogin这个actionjsp文件:
    <s:form action="userLogin"> 
      

  12.   

    问题解决,原来是bulid目录下的classes目录要放到WEB-INF目录来。。
    感谢各位