首页 \ 问答 \ Struts2没有针对命名空间[/]映射的Action和与上下文路径[/ Struts2Test]关联的操作名称[login](Struts2 There is no Action mapped for namespace [/] and action name [login] associated with context path [/Struts2Test])

Struts2没有针对命名空间[/]映射的Action和与上下文路径[/ Struts2Test]关联的操作名称[login](Struts2 There is no Action mapped for namespace [/] and action name [login] associated with context path [/Struts2Test])

我是Struts2的初学者,我知道这个问题已经在这里问了很多次,但我试着解决它并在这里阅读了很多线程,花了6个小时仍然无法让它工作。 真的需要更多的建议......

这是我的包裹

Struts2Test
  +Struts2Test/src
    +tw.com.rrstudio.java.test
      -TestAction.java
  +Struts2Test/build
  +Struts2Test/WebContent
    +Struts2Test/WebContent/META-INF
      +Struts2Test/WebContent/WEB-INF/classes
      +Struts2Test/WebContent/WEB-INF/lib
      -Struts2Test/WebContent/WEB-INF/spring-context.xml
      -Struts2Test/WebContent/WEB-INF/spring-mvc.xml
      -Struts2Test/WebContent/WEB-INF/struts.xml
      -Struts2Test/WebContent/WEB-INF/struts2-action.xml
      -Struts2Test/WebContent/WEB-INF/web.xml
    -Struts2Test/WebContent/error.jsp
    -Struts2Test/WebContent/index.jsp
    -Struts2Test/WebContent/TestAction.jsp

我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  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>Struts2Test</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      /WEB-INF/spring-context.xml
      /WEB-INF/spring-mvc.xml
    </param-value>
  </context-param>

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

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    <init-param>
      <param-name>actionPackages</param-name>
      <param-value>tw.com.rrstudio.java.test</param-value>
    </init-param>
  </filter>

  <jsp-config>
    <taglib>
      <taglib-uri>HTTP://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/lib/tld/c.tld</taglib-location>
    </taglib>
    <jsp-property-group>
      <url-pattern>*.jsp</url-pattern>
      <page-encoding>UTF-8</page-encoding>
    </jsp-property-group>
  </jsp-config>

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

  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

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

</web-app>

还有,struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
  <!-- struts 2.3.16.3 has problem of security,needing to set DynamicMethodInvocation=false -->
  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
  <constant name="struts.devMode" value="false" />

  <constant name="struts.objectFactory" value="spring" />

  <constant name="struts.action.extension" value="do"/>
  <constant name="struts.action.excludePattern" value="/jsp/.*?,/image/.*?,/css/.*?,/js/.*?,.*\\.jsp"/>

  <package name="default" extends="json-default" ></package>

  <package name="Strut2Test" extends="json-default" >
    <global-results>
      <result name="SystemErrorPage">/WebContent/error.jsp</result>
    </global-results>
    <action name="login" class="tw.com.rrstudio.java.test.TestAction">
      <result name="index">/WebContent/index.jsp</result>
      <result name="success">/WebContent/TestAction.jsp</result>
    </action>
  </package>

</struts>

的index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=login.action">
<title>Index of Struts2Test</title>
</head>
<body>
  <h1>Index of Struts2Test</h1>
  <form action="testAction" method="post">
    <label for="name">Please enter your name</label><br/>
    <input type="text" name="name"/>
    <input type="submit" value="Say Hello"/>
  </form>
</body>
</html>

服务器是Tomcat 8.0.38,它没有错误。 但是当我访问时

它给了我这个(作为标题)错误,如果我访问

我会定期得到404结果。

现在我不知道,欢迎提出任何建议或提示......


I'm a beginner of Struts2, I know this question been asked in here much times, but I tried to solve it and read much much threads here, spend 6 hours and still can't get it work. Really need more suggestion...

Here's my Package

Struts2Test
  +Struts2Test/src
    +tw.com.rrstudio.java.test
      -TestAction.java
  +Struts2Test/build
  +Struts2Test/WebContent
    +Struts2Test/WebContent/META-INF
      +Struts2Test/WebContent/WEB-INF/classes
      +Struts2Test/WebContent/WEB-INF/lib
      -Struts2Test/WebContent/WEB-INF/spring-context.xml
      -Struts2Test/WebContent/WEB-INF/spring-mvc.xml
      -Struts2Test/WebContent/WEB-INF/struts.xml
      -Struts2Test/WebContent/WEB-INF/struts2-action.xml
      -Struts2Test/WebContent/WEB-INF/web.xml
    -Struts2Test/WebContent/error.jsp
    -Struts2Test/WebContent/index.jsp
    -Struts2Test/WebContent/TestAction.jsp

My web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  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>Struts2Test</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      /WEB-INF/spring-context.xml
      /WEB-INF/spring-mvc.xml
    </param-value>
  </context-param>

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

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    <init-param>
      <param-name>actionPackages</param-name>
      <param-value>tw.com.rrstudio.java.test</param-value>
    </init-param>
  </filter>

  <jsp-config>
    <taglib>
      <taglib-uri>HTTP://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/lib/tld/c.tld</taglib-location>
    </taglib>
    <jsp-property-group>
      <url-pattern>*.jsp</url-pattern>
      <page-encoding>UTF-8</page-encoding>
    </jsp-property-group>
  </jsp-config>

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

  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

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

</web-app>

And also, struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
  <!-- struts 2.3.16.3 has problem of security,needing to set DynamicMethodInvocation=false -->
  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
  <constant name="struts.devMode" value="false" />

  <constant name="struts.objectFactory" value="spring" />

  <constant name="struts.action.extension" value="do"/>
  <constant name="struts.action.excludePattern" value="/jsp/.*?,/image/.*?,/css/.*?,/js/.*?,.*\\.jsp"/>

  <package name="default" extends="json-default" ></package>

  <package name="Strut2Test" extends="json-default" >
    <global-results>
      <result name="SystemErrorPage">/WebContent/error.jsp</result>
    </global-results>
    <action name="login" class="tw.com.rrstudio.java.test.TestAction">
      <result name="index">/WebContent/index.jsp</result>
      <result name="success">/WebContent/TestAction.jsp</result>
    </action>
  </package>

</struts>

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=login.action">
<title>Index of Struts2Test</title>
</head>
<body>
  <h1>Index of Struts2Test</h1>
  <form action="testAction" method="post">
    <label for="name">Please enter your name</label><br/>
    <input type="text" name="name"/>
    <input type="submit" value="Say Hello"/>
  </form>
</body>
</html>

The Server is Tomcat 8.0.38, it starts with no error. But when I access

it gives me this(as title) error, and if I access

I will get a regular 404 result.

Now I have no idea, any suggestions or tips are welcome...


原文:https://stackoverflow.com/questions/40650763
更新时间:2022-05-24 14:05

最满意答案

简短的回答:他们都加载了一个numpy数组 。 唯一的区别是用于加载它们的方法。 我建议使用scipy's甚至使用scikits-image

来自matplotlib的imread文档

返回值是numpy.array。 对于灰度图像,返回数组是MxN。 对于RGB图像,返回值为MxNx3。 对于RGBA图像,返回值为MxNx4。

来自scipy的imread文档

返回:
imread:ndarray通过从文件imfile中读取图像获得的数组。

(由ndarray提供给numpy.ndarray因为scipy建立在numpy之上)。

Scikits-image支持其他插件而不是PIL ,例如我们的freeimage或库tifffile ,甚至是matplotlib本身。 查看scikits-image支持的所有插件/库, 以加载和保存图像


Short answer: both of them load a numpy array. The only difference is the methods used to load them. I would suggest using scipy's or even use scikits-image.

From matplotlib's imread documentation:

Return value is a numpy.array. For grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4.

From scipy's imread documentation:

Returns:
imread : ndarray The array obtained by reading image from file imfile.

(By ndarray refeers to a numpy.ndarray as scipy is built on top of numpy).

Scikits-image's supports others plugins than PIL, such us freeimage or the library tifffile, or even matplotlib itself. Have a look at all the plugins/libraries supported by scikits-image to load and save images.

相关问答

更多
  • SciPy 中包含一些用于输入和输出的实用模块。下面介绍其中两个模块:io 和misc。 以图像形式保存数组 因为我们需要对图像进行操作,并且需要使用数组对象来做运算,所以将数组直接保存为图像文件1 非常有用。本书中的很多图像都是这样的创建的。 imsave() 函数可以从scipy.misc 模块中载入。要将数组im 保存到文件中,可以使用下面的命令: from scipy.misc import imsave imsave('test.jpg',im) scipy.misc 模块同样包含了著名的Lena ...
  • 每当你遇到一种情况,你不知道某些代码在做什么,并且在一些解释器中简单地导入父模块并检查代码的执行情况,文档字符串等等,并不容易,那么你有一些选项。 让我来描述一下这两个选项,这次没有太大的帮助,但是这是一个很好的方式,可以在将来开始这样的问题(这样你就可以包含这些尝试的输出,以便向人们证明你尝试过在发布之前有些东西,并且想知道这些东西是什么): 您可以使用dis模块将Python代码反汇编为执行的操作码,如下所示: python -c "import dis; from scipy import misc; ...
  • scipy.misc模块在历史上是作为收集不容易融入其他SciPy子模块的功能的地方而存在的。 它将被弃用,不应使用。 在Python生态系统中,我建议使用imageio来读取图像(或者matplotlib.pyplot.imread ,如果您已经在使用matplotlib )。 Scikit-image为所有这些I / O库提供了一个方便的包装,就像skimage.io (它应该已经安装在你的系统上)。 它还可确保将图像转换为正确的数据类型和范围格式,以便与其他skimage功能一起使用(请参阅http: ...
  • 由值[0,1,10]组成的输入数组实际上不是图像数组。 图像数组将从0到255或从0.到1. 。 一个。 使用LinearSegmentedColormap 一个想法可以是将数组im标准化为1: im = im/im.max() 。 然后可以使用matplotlib.colors.LinearSegmentedColormap.from_list创建值为0 -> white, 0.1 -> green, 1 -> red matplotlib.colors.LinearSegmentedColormap.f ...
  • 我能够在Cloud ML上重现此问题,并且它似乎是Tensorflow 0.12.1中file_io版本的问题,如果安装了Tensorflow 1.0,则会消失。 如果可以的话,升级到TF的1.0版本。 如果您需要0.12版本,Cloud ML“0.12”运行时使用TF的0.12.1官方版本,但如果您愿意,您可以上传自己的版本进行安装。 我没有确切地追踪问题的解决方案,但是2月2日的Nightly Tensorflow似乎有效。 I was able to reproduce this issue on C ...
  • 是的,默认情况下它读取BGR,如果要读取灰度图像,则需要在imread中使用第二个参数。 从文档 : 阅读一张图片 使用函数cv2.imread()读取图像。 图像应该在工作目录中,或者应该给出完整的图像路径。 第二个参数是一个标志,指定应该读取图像的方式。 cv2.IMREAD_COLOR:加载彩色图像。 任何图像的透明度都将被忽略。 这是默认标志。 cv2.IMREAD_GRAYSCALE:以灰度模式加载图像 cv2.IMREAD_UNCHANGED:加载包含alpha通道的图像注意:除了这三个标志,您 ...
  • 简短的回答:他们都加载了一个numpy数组 。 唯一的区别是用于加载它们的方法。 我建议使用scipy's甚至使用scikits-image 。 来自matplotlib的imread文档 : 返回值是numpy.array。 对于灰度图像,返回数组是MxN。 对于RGB图像,返回值为MxNx3。 对于RGBA图像,返回值为MxNx4。 来自scipy的imread文档 : 返回: imread:ndarray通过从文件imfile中读取图像获得的数组。 (由ndarray提供给numpy.ndarray因 ...
  • 使用%matplotlib inline后端 %matplotlib inline后端将matplotlib图显示为png图像。 您可以使用IPython.display显示图像,并在这种情况下显示一段时间后的另一个图像。 import matplotlib.pyplot as plt import matplotlib.image as mpimg from IPython import display import time %matplotlib inline PATH = "../data/ko ...
  • 解决了! 安装PIL时没有安装Libjpeg。 所以我这样做了: pip uninstall PIL brew install libjpeg pip install PIL 它的工作原理。 我从这里得到了提示: https://stackoverflow.com/a/12194881/11522 Solved! Libjpeg wasn't installed when I installed PIL. So I did this: pip uninstall PIL brew install libj ...
  • 这将是一个真正的mcve: import matplotlib.pyplot as plt import numpy as np import scipy.ndimage im = np.random.rand(20,20) plt.imsave("img.png",im) ### Scipy i2 = scipy.ndimage.imread("img.png") print i2.shape, i2.min(), i2.max(), i2.dtype # (20L, 20L, 4L) 1 255 u ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。