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
最满意答案
简短的回答:他们都加载了一个numpy数组 。 唯一的区别是用于加载它们的方法。 我建议使用scipy's甚至使用scikits-image 。
返回值是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 anumpy.ndarray
as scipy is built on top of numpy).Scikits-image's supports others plugins than
PIL
, such usfreeimage
or the librarytifffile
, or evenmatplotlib
itself. Have a look at all the plugins/libraries supported by scikits-image to load and save images.
相关问答
更多-
python scipy.misc什么用[2024-04-29]
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 ...
-
scipy.misc.imread创建一个没有大小或形状的图像(scipy.misc.imread creates an image with no size or shape)[2023-02-22]
解决了! 安装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 ...