gpt4 book ai didi

eclipse - 没有为命名空间 [/] 和 Action 名称 [] 映射的 Action 与上下文路径 [/struts] 关联

转载 作者:行者123 更新时间:2023-12-04 11:39:53 25 4
gpt4 key购买 nike

我已经查看了 stackoverflow 上所有类似的问题,但没有帮助,抱歉。我与他们的主要区别是我在错误消息中得到了 EMPTY 操作名称。谷歌搜索没有帮助:( 希望有人可以提示在哪里寻找问题的根源。谢谢

消息:

    Stacktraces
There is no Action mapped for namespace [/] and action name [] associated with context path [/struts]. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58
..................

struts.xml:

    <?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>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/*" extends="struts-default">
<action name="login"
class="training.struts.action.LoginAction">
<result>login.jsp</result>
</action>
</package>
</struts>

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_2_5.xsd"
version="2.5">

<display-name>Struts Lab</display-name>

<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>

<!-- Spring Config -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/springServlet/appServlet/mvc-servlet.xml,
/WEB-INF/db/db-cfg.xml,
/WEB-INF/springServlet/application-security.xml
</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springServlet/appServlet/mvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

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

<!-- *** -->
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>

好吧..image是不可能的,所以项目结构是:

src/main/java
----+training.struts.action.LoginAction.java
src/main/webapp
----+WEB-INF
--------+classes
-----------+struts.xml
--------+db
-----------+db-cfg.xml
--------+springServlet
-----------+appServlet
---------------+mvc-servlet.xml
-----------+application-security.xml
--------+index.jsp
--------+login.jsp
--------+web.xml

更新:傻了好难过=(我已将 login.jsp 从 WEB-INF 移至 webapp root 并解决了问题。

更新 2:我做了一些调查:如果我从 web.xml 中删除“welcome-file-list” block ,容器将在 webapp 根目录中查找“index.jsp”,以显示为应用程序运行的第一个 View 。如果我删除“index.jsp”,那么我会得到相同的异常消息:没有为命名空间 [/] 和 Action 名称 [] 映射的 Action 与上下文路径 [/struts] 关联

所以在我看来,如果您在错误消息中有空的操作名称以及正确的 struts xml 设置,那么第一步应该是启动 JSP 可用性检查。

干杯,伙计们。

最佳答案

将以下空白操作添加到 "/" 包命名空间中的 struts.xml 文件中,当您仅尝试访问您的 url(如 appid.app. com),它不会显示错误。通常它会添加一个空白操作,应用引擎会将空白操作重定向到您的欢迎文件。

    <action name="" class="com.candi.actions.Dashboard" method="noAction">
<result name="success">index.jsp</result>
</action>

关于eclipse - 没有为命名空间 [/] 和 Action 名称 [] 映射的 Action 与上下文路径 [/struts] 关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17829388/

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