标签: struts2-namespace

Struts Hello world示例:没有映射名称空间[/]和操作名称错误的Action

我绝对是Struts2的初学者.我想跟随struts网站上的教程.我按照本教程.我有点麻烦.我在eclipse上创建了动态web项目.然后我按照教程.但是,当我运行该示例时,我收到以下错误.

There is no Action mapped for namespace [/] and action name [hello] associated with context path [/Hello_World_Struts_2]. - [unknown location]
Run Code Online (Sandbox Code Playgroud)

我有以下目录结构

在此输入图像描述

我的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="basicstruts2" extends="struts-default" namespace="/">

  <action name="index">
    <result>/index.jsp</result>
  </action>

  <action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
    <result name="SUCCESS">/HelloWorld.jsp</result>
  </action>

</package>

</struts>
Run Code Online (Sandbox Code Playgroud)

谢谢你的回复.

struts2 struts2-namespace action-mapping

11
推荐指数
1
解决办法
4万
查看次数

在tile中使用多个Struts2名称空间

我想在struts2配置中添加命名空间,并使用tile.

我的struts.xml包,例如:

<package name="search" namespace="/search" extends="struts-default"> 
<result-types>
    <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="SearchActionInit"  class="web.action.SearchAction" method="initSearch"> 
   <result name="input" type="tiles">search</result> 
   <result name="success" type="tiles">search</result> 
</action> 
</package>
Run Code Online (Sandbox Code Playgroud)

和相应的瓷砖配置:

<definition name="baseLayout"    template="layout.jsp">
    <put-attribute name="titre"               value="titre.default" />
    <put-attribute name="header"            value="/common/header.jsp" />
    <put-attribute name="menu"          value="/common/menu.jsp" />
    <put-attribute name="leftcontent"          value="/common/leftcontent.jsp" />
    <put-attribute name="rightcontent"          value="/common/rightcontent.jsp" />
    <put-attribute name="detail"          value="/common/detail.jsp" />
    <put-attribute name="footer"               value="/common/footer.jsp" />
</definition>

<definition name="search"    extends="baseLayout">
    <put-attribute name="titre"               value="titre.search" />
    <put-attribute name="rightcontent"          value="/pages/search/Search.jsp" />
</definition>
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是我需要在搜索文件夹中复制layout.jsp以进行命名空间搜索(对于其他命名空间,依此类推).它不在tile逻辑中,并且会为维护带来更多努力.

有没有人解决这个问题,以避免重复?

struts2 tiles struts2-namespace

5
推荐指数
1
解决办法
1973
查看次数

如何防止struts中的通配符命名空间?

我遇到了一个问题,我无法找到关键词来解决以下情况:

<package name="Main" namespace="/" extends="struts-default">
    <action name="administrator" class="com.xyz.AdminAction">
        <result name="success">/WEB-INF/jsp/admin.jsp</result>
    </action>
</package>
Run Code Online (Sandbox Code Playgroud)

上面的网址应该是http://xyz.com/administrator,它运行正常.但是,如果我将网址更改为http://xyz.com/asdasd/asdasdasd/administrator,它仍然有效,但我不能接受这个!那么任何告诉struts的设置只接受http://xyz.com/administrator吗?谢谢!

struts2 struts2-namespace

4
推荐指数
1
解决办法
2617
查看次数

对于与上下文路径关联的名称空间[/]和操作名称[],没有映射的Action

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

Error:

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [] associated with context path [/LoginApplication].

--------------------------------------------------------------------------------

type Status report

message There is no Action mapped for namespace [/] and action name [] associated with context path [/LoginApplication].

description The requested resource (There is no Action mapped for namespace [/] and action name [] associated with context path [/LoginApplication].) is not available.

WARNING: Could not find action or result: /LoginApplication/
There is no …
Run Code Online (Sandbox Code Playgroud)

struts2 struts2-namespace action-mapping

4
推荐指数
2
解决办法
6万
查看次数

struts2忽略特定模式

我正在使用strust2进行Web应用程序开发.我的struts.xml文件将是:

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="default" extends="struts-default" namespace ="/">
        <action name="signup">
            <result>/check.jsp</result>
        </action>
    </package>
</struts>
Run Code Online (Sandbox Code Playgroud)

我的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" id="WebApp_ID" version="2.5">
  <display-name>sample</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>

  <servlet>
    <servlet-name>My WS</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>com.dr1.dr2</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>My WS</servlet-name>
    <url-pattern>/checking</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
Run Code Online (Sandbox Code Playgroud)

现在,如果我访问如下:http:// localhost:8080/appName /它完全进入我的注册操作.但是,当我尝试访问 http:// localhost:8080/appName/checking(对于webservices)时,它甚至在struts.xml中查找并收到如下错误消息:

HTTP状态404 - 没有映射名称空间/和操作名称检查的Action...甚至在web.xml中定义之后..

有没有办法在struts2中排除一个模式,所以当我点击http:// …

struts2 struts2-namespace

2
推荐指数
1
解决办法
8791
查看次数