`
AngSi
  • 浏览: 7977 次
  • 性别: Icon_minigender_1
  • 来自: 成都
最近访客 更多访客>>
社区版块
存档分类
最新评论

警告: No configuration found for the specified action: '/myNameSpace/login.action'

阅读更多

今天首次使用Struts2,配置一切正常,使用常用tag也正常,但是在使用<s:form>标记时,发现控制台总是输出警告信息, 

警告信息内容如下: 

警告: No configuration found for the specified action: 'ShowMessage' in namespace: ''. Form action defaulting to 'action' attribute's literal value. 
2008-9-6 11:35:47 org.apache.struts2.components.Form evaluateExtraParamsServletRequest 
警告: No configuration found for the specified action: 'ShowMessage' in namespace: ''. Form action defaulting to 'action' attribute's literal value. 

showmsg.jsp代码如下 

<%@ taglib prefix="s" uri="/struts-tags" %> 
...... 
<div> 
hello world 
<s:form name="ShowMessage" method="post" action="/hello/ShowMessage.action" > 
<s:textfield label="user name" name="username"></s:textfield> 
<s:submit></s:submit> 
</s:form> 
</div> 
...... 

struts.xml配置如下: 
...... 
<struts> 
<package name="hello" extends="struts-default" namespace="/hello"> 
<action name="ShowMessage" class="com.historycreator.strutstest.ShowMessage"> 
<result>/digg/showmsg.jsp</result> 
</action> 
</package> 
</struts> 

打开showmsg.jsp页面时,就出现上述异常。尝试了各种配置和访问方法,均出现警告。搜索网络给出的答案几乎都说把<s:form name="ShowMessage" method="post" action="/hello/ShowMessage.action" >中的.action去掉就可以解决了,做了测试,问题仍然没有解决。更有人让把<s:去掉,不用tag,直接写<form>这个当然不会有问题,但是一会用标记,一会不用,很杂乱,并且不是解决问题的根本之道。 

解决方法: 
经过测试发现,是没有正确使用tag的原因,这种情况下,正确的写法应该是,<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" > 


原因分析: 

因为开始使用的struts2标签(form)并未指定namespace属性。所以struts2会默认从根命名空间"/" 搜索action '/hello/ShowMessage.action',如搜索不到则进入默认命名空间''搜索action串,在默认命名空间中是肯定找不到自己定义的action的,所以,struts2抛出一个警告信息。 

现在我们指定了namespace为/hello,则struts2会直接在/hello命名空间寻找。可以想象,如果在这么命名空间里找不到请求的action,也会抛出一条类似的信息。 

注意,<s:form name="ShowMessage" method="post" action="ShowMessage" namespace="/hello" > 
不能写成<s:form name="ShowMessage" method="post" action="ShowMessage.action" namespace="/hello" > 

这样仍然有对应的警告信息,并且提交后出现无法访问的结果。因为没有ShowMessage.action这样一个action,这个.action不能由我们手工添加,Struts2会自动为你完成这个工作,并且手工添加是不行的,就不必多此一举了。但是在其他的场合,比如使用超级链结,则可以加上这个.action。

分享到:
评论

相关推荐

    warning ..\package.json: No license field

    在初始化Vue项目的的时候发现警告 yarn install 查了下发现是,package.json 文件中缺少license参数 { name: movie_view, version: 0.1.0, license: MIT, private: true, scripts: { serve: vue-cli-...

    Rational Interger

    Rational Interger

    Web Navigation

    VISIT : Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied. QUIT: Quit the browser. Assume that the browser ...

    squashfs1.3r3.tar.gz

    or ./) the entry is treated as absolute, however, if an exclude file/directory is relative, it is treated as being relative to each of the sources in turn, i.e. %mksquashfs /tmp/source1 source2 ...

    最快捷的IP备份工具

    For Release and Renew, if no adapter name is specified, then the IP address leases for all adapters bound to TCP/IP will be released or renewed. For Setclassid, if no ClassId is specified, then ...

    EurekaLog_7.5.0.0_Enterprise

    17)..Added: Support for relative file paths and environment variables for events and various module paths 18)..Added: Logging in Manage tool 19)..Added: Windows 10 version detection 20)..Added: Stack ...

    EEUPDATE刷MAC工具 EEUPDATE v5.30.10.00

    Selects all adapters found in the system. /NIC=XX Selects a specific adapter (1-32). /BUS=XX Selects PCI bus of adapter to program. Must be used with the DEV parameter to specify an adapter. /...

    LINUX gd-2.0.35.tar.gz

    If the DIR argument is specified, configure tries to find the png header files in DIR/include, and the libraries in DIR/lib. To accommodate OpenBSD ports, DIR/include/libpng is also checked if ...

    yaffs_vfs.c, android

    fs/yaffs2/yaffs_vfs.c:2390:2: error: unknown field 'get_sb' specified in initializer fs/yaffs2/yaffs_vfs.c:2390:2: warning: initialization makes integer from pointer without a cast fs/yaffs2/yaffs_vfs...

    UE(官方下载)

    You can use these functions to insert a file into the current file, delete the active file, send the file through email, or insert a string into the file at every specified increment HTML preview ...

    tensorflow-1.12支持cuda10.0

    Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by ...

    google api php client

    The method used is a matter of preference, but *it will be very difficult to use this library without first understanding the JSON syntax for the API*, so it is recommended to look at the [APIs ...

    MyBase Desktop 6.0.2 破解正式版(官方更新至10/10/2011)

    8.Added: the 'Organize' menu onto the main menu, as many users can't find the 'Sort child items' utility, which is also located in the 'Outline' action menu. 9.Added: Alt-Drag to create symbolic links...

    apktool documentation

    // builds current directory into ./dist $ apktool b bar -o new_bar.apk // builds bar folder into new_bar.apk $ apktool b bar.apk // WRONG: brut.androlib.AndrolibException: brut.directory....

    nao机器人java语音源码

    /// Performs the text-to-speech operations: it takes a std::string as input and outputs the corresponding audio signal in the specified file. /// &lt;/summary&gt; /// &lt;param name="pStringToSay"&gt; Text to ...

    CrashSenderexe.zip

    报错crashsender.exe is not found the specified path

    关于IllegalStateException: The specified child already has a parent.

    IllegalStateException: The specified child already has a parent.我的博客中有文章讲解

    STG (SNMP Traffic Grapher)

    You may charge a fee for the physical act of transferring a copy only. This program is distributed WITHOUT ANY WARRANTY. Use it at your own risk. I cannot guarantee accuracy of displayed data. I...

    ASP.NET The system cannot find the file specified解决办法

    ASP.NET The system cannot find the file specified解决办法 Server Error in ‘/’ Application. The system cannot find the file specified Description: An unhandled exception occurred during the execution...

    postgresql缺少文件

    问题链接:https://blog.csdn.net/u011043673/article/details/103099092 在 postgresql 加载timescaledb 时报:could not load library timescaledb-1.4.2.dll The specified procedure could not be found.

Global site tag (gtag.js) - Google Analytics