gpt4 book ai didi

java - 使用 struts2 为命名空间错误映射的操作

转载 作者:行者123 更新时间:2023-11-30 11:38:55 24 4
gpt4 key购买 nike

我在使用 Struts2 时遇到这个错误

There is no Action mapped for namespace [/] and action name [LoginAction] 
associated with context path [/TestBoard]. - [unknown location]

项目上下文根 = TestBoard

这是我的 struts.xml:

<struts>
<constant name="struts.serve.static.browserCache" value="false" />
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.action.extension" value="" />

<package name="strutsPkg" extends="struts-default" namespace="/">

<interceptors>
<interceptor name="loginCheck" class="com.finger.fwebframework.action.LoginSessionCheck">
<!--<param name="excludeActions">/LoginAction.action,/LoginIndexAction.action,/CUMQryCustMenuFrameListAction.action,/CUMQryCustSuppHstFrameListAction.action,/CUMQryLnkTgtSysPermtFrameListAction.action,/CUMQryRsrchInstFrameListAction.action,/CUMQrySchInfoFrameListAction.action</param>-->
<param name="excludeActions">/LoginAction.action,/LoginIndexAction.action,\/[\w]*Frame[\w]*Action.action,\/[\w]*PopAction.action</param>
<param name="redirectWebPage">/login.jsp</param>
</interceptor>

<interceptor-stack name="srcmsStack">
<interceptor-ref name="defaultStack"/> <!-- struts-default.xml support -->
<interceptor-ref name="loginCheck"/>
<interceptor-ref name="validation"> <!-- No result defined for action support -->
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="srcmsStack"/>
</package>

<include file="com/finger/fwebframework/struts/Struts_com.xml"></include>
</struts>

这是我的 Web.xml

    <!-- siteMesh -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>

<!-- struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.i18n.encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>NoCache</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<session-config>
<session-timeout>10</session-timeout>
</session-config>

<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

这是我的 login.jsp

    <%@ taglib prefix="s" uri="/struts-tags" %>

<head>
<meta http-equi="Content-Type" content="text/html; charset=utf-8"/>
<script>
$("#loginButton").click(function() {
if ($.validate()) {
$("#frmLogin").attr('action', 'LoginAction.action').submit();
};
});
</script>
</head>
<body id="bdy" class="main_bg" >
<s:form id="frmLogin">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" >
<tr>
<td>ID: </td>
<td><input type = "text" name = "ID" id ="ID" /></td>
</tr>

<tr>
<td>PW : </td>
<td><input type = "password" name = "PW" id ="PW"/></td>
</tr>

<tr>
<td><input type = "button" id ="loginButton" value="Log_In"/></td>
</tr>
</table>
</s:form>
</body>

我做错了什么,我该如何解决这个问题?

请回答我。

最佳答案

查看错误信息 “没有为命名空间 [/] 和操作名称 [LoginAction] 映射的操作”在你的 struts.xml 中我没有找到任何 Action 标签你可以试试插入

<action name="LoginAction" class="com.xxx" method="">
<result>/index.jsp</result>
</action>

关于java - 使用 struts2 为命名空间错误映射的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13505480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com