码迷,mamicode.com
首页 > 移动开发 > 详细

There is no Action mapped for namespace [/] and action name [LoginAction_home] associ

时间:2014-12-06 06:43:14      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:action namespace

使用struts2框架产生的问题:

index.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<jsp:forward page="/login/login.jsp"></jsp:forward>

login.jsp:

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<script type="text/javascript">
function ini(){
   document.form1.loginName.focus();
}
</script>
<html>
    <head>
        <meta http-equiv="Content-Language" content="zh-cn">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link href="${pageContext.request.contextPath}/css/Style.css" rel="stylesheet" type="text/css">
    </head>
    <body onload="ini()">
        <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td align="center">
                    <table width="452" height="290" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td bgcolor="#FFFFFF">
                                <table width="452" height="290" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td height="74">
                                            <img src="${pageContext.request.contextPath}/images/logintitle.gif">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" valign="bottom" background="${pageContext.request.contextPath}/images/loginbg.gif">
                                            <s:form id="form1" name="form1"  action="LoginAction_home.do" target="_parent" method="post">    
                                                <table border="0" align="center" cellpadding="2" cellspacing="0">
                                                    <tr align="center">
                                                        <td height="30" colspan="2" style="border-bottom: 1px dotted #cccccc">
                                                            <strong style="font-size: 14px;">请登录</strong>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="30" nowrap>
                                                            <font color="000F60"><strong>用户名:</strong> </font>
                                                        </td>
                                                        <td>
                                                            <s:textfield name="loginName" id="loginName" class="text" style="width: 160px;"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="30" nowrap>
                                                            <strong><font color="000F60">密码: </font> </strong>
                                                        </td>
                                                        <td>
                                                            <s:password name="loginPsw" id="loginPsw"  class="text" style="width: 160px;"/>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="30" nowrap colspan="2">
                                                            <strong><s:fielderror/><font color="red"></font> </strong>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="30">
                                                        </td>
                                                        <td>
                                                            <s:submit type="button" name="submit" value="登录" class="buttoninput"></s:submit>
                                                            <s:reset type="button" name="reset" value="取消" class="buttoninput"></s:reset>
                                                        </td>
                                                    </tr>
                                                </table>
                                                </s:form>
                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td height="30" align="center">
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td height="23" align="center"></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>
</html>

这里所填写的form表单 namespace="/login"action=" LoginAction_home.do",会造成的问题是:

  • There is no Action mapped for namespace [/] and action name [LoginAction_home] associated with context path [/itcast1109_project].

            *index.jsp直接指向login.jsp,通过访问index.jsp,点击"登录",
                *结果会报错:There is no Action mapped for namespace [/] and action name[LoginAction_home] associated with context path[/]......
                *原因:index.jsp是工程目录的根目录下,导致在index.jsp页面识别不出namespace    

改为action="/login/LoginAction_home.do"就可以了

There is no Action mapped for namespace [/] and action name [LoginAction_home] associ

标签:action namespace

原文地址:http://vincent1992.blog.51cto.com/4621739/1586772

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!