Icce___ 2015-06-19 08:23 采纳率: 66.7%
浏览 7621
已结题

struts2 action找不到404

刚学习struts2,做到登录功能的时候登录按钮点击之后就显示action404的页面
我的工程结构是这样的
图片说明

web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>ieZhan</display-name>
  <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</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>  
</web-app>

struts.xml


<package name="struts2" extends="struts-default" namespace="/">
      <action name="login" class="com.login.struts2.loginAction">
          <result name="success" type="redirect">/aboutus.jsp</result>
          <result name="failer" type="redirect">/contactus.jsp</result>    
      </action>
</package>

jsp页面中的form代码

 <s:form action="login" >
            <ul class="login_cont">
                <li class="f14">会员登录</li>
                <li class="login_ipt"><p><span class="fl tr">账号:</span><input type="text" class="login_txt fl" name="username"/></p></li>
                <li class="login_ipt"><p><span class="fl tr">密码:</span><input type="password" class="login_txt fl" name="password"/></p></li>
                <li><a href="#" class="fr">忘记登录密码?</a><label><input type="checkbox" class="remember_psw" />记住密码</label></li>
                <li class="mt10"><button class="login_button login_button_signup" type="submit" >登录</button></li>
            </ul>
            </s:form>

在启动tomcat的时候有出现警告
六月 19, 2015 3:59:32 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: 'loginAction' in namespace: '/pages'. Form action defaulting to 'action' attribute's literal value.
六月 19, 2015 3:59:33 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: 'loginAction' in namespace: '/pages'. Form action defaulting to 'action' attribute's literal value.

我看了下在页面上的action的url是
图片说明

我试过加namespace=“/” 路径变成/ieZhan/login 也不行
希望有好心人帮忙解决下。

  • 写回答

9条回答 默认 最新

  • SimbaLi123 2015-06-19 08:41
    关注
    在页面上面加上
    <%  
    String path = request.getContextPath();  
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
    %> 
    
    form的  action里面写
    action="<%=basePath%>login"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块
  • ¥15 nhanes加权logistic回归,svyglm函数