警告: No configuration found for the specified action: '/myNameSpace/login.action' in names
今天花了点时间把struts2警告事件彻底的测试了一边,终于有点眉目了。希望能给其他人带来一点帮助。文章属于原创。并不需要转载的时候注明出处,而是希望转载的朋友一定要看明白本文内容再转载,因为我你都清楚,现在去google或百度得到的解决方案多数是一致的,说俗点大家都是相互转载的,这不是问题,问题是转载的解决方案有时并不是最理想的答案,简单的说垃圾信息过多。这造成求知者大量的时间流失。希望转贴者要对自己及网民负责。
警告信息:
警告: No configuration found for the specified action: '/myNameSpace/login.action' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
struts.xml配置信息(部分)
<package name="packageName" extends="struts-default" namespace="/myNameSpace">
<action name="login" class="com.jato.srvclink.test.login.LoginAction" method="login">
jsp页面配置信息(部分)
<s:form action="/myNameSpace/login.action">
思考:没有在''的namespace中发现指定的action '/myNameSpace/login.action'
答疑:因为配置的struts2标签并未指定namespace属性。所以struts2会默认从根命名空间"/"搜索action串'/myNameSpace/login.action',如果搜索不到将进入默认命名空间''搜索action请求串,在默认命名空间中是肯定找不到我们定义的action的,所以,struts2抛出一个警告信息。
但是为什么我们没有填写namespace,我们的请求也可以正常访问呢?
我们来看一下解析后的html
查看源码得到的html(部分)
<form id="login" onsubmit="return true;" action="/srvclink/myNameSpace/login.action" method="post">
我们看到form提交的action串是准确的url请求,action串确实是/srvclin(应用根)/myNameSpace(命名空间)/login.action。
命名空间中找不到action定义,并不意味着这个action真的不存在,只是我们的代码有问题而已。还有一点是我们在jsp页面的action请求中手动的加入了.action后缀。事实上struts2会自动追加.action的,因为我们并没有合法的使用struts2的标签,所以struts2这里并没有给我们追加.action,解析后的代码中存在的.action,完全是我们手动在jsp页面填写的,有疑问的网友可以不手动添加查看html。
我们修改我们的程序代码
jsp页面配置信息(部分)修改后加入namespace属性,修改action属性值为/login.action
<s:form action="/login.action" namespace="/myNameSpace">
请求页面后,大家很失望吧?警告依然存在。但是我们看一下警告信息。
警告信息:
警告: No configuration found for the specified action: '/login.action' in namespace: '/myNameSpace'. Form action defaulting to 'action' attribute's literal value.
没有在'/myNameSpace'的namespace中发现指定的action '/login.action'
毫无疑问,这里的警告和第一次的警告信息截然不同。我们现在存在命名空间,'/myNameSpace'能够被struts2检索到,并不是开始的''。那问题的关键在哪里呢?
在namespace中没有发现指定的action '/login.action' ???
我们来看一下struts.xml中的配置:
struts.xml配置信息(部分)
<package name="packageName" extends="struts-default" namespace="/myNameSpace">
<action name="login" class="com.jato.srvclink.test.login.LoginAction" method="login">
是的,我们'/myNameSpace'命名空间下,只有action名字为'login'的定义,并没有所谓的 '/login.action' 定义,所以struts2的警告并未错。如果大家对这个抱有怀疑,可以修改action的名字'login'为‘/longin.action’
<action name="/login.action" class="com.jato.srvclink.test.login.LoginAction" method="login">
请求页面时你会发现不在报警告信息,原因很简单。因为在命名空间为'myNameSpace'下确实存在命名为'/login.action'的action。
我们再次修改配置文件
jsp页面配置信息(部分)修改后action属性值为longin
<s:form action="login" namespace="/myNameSpace">
请求页面时,我们发现不再有警告信息了。
如果你有足够细心,我想你应该可以彻底的明白为什么struts2会报警了吧?你也应该明白了使用struts2标签action中添加/线后请求反而报错的原因了。
分享到:
相关推荐
在初始化Vue项目的的时候发现警告 yarn install 查了下发现是,package.json 文件中缺少license参数 { name: movie_view, version: 0.1.0, license: MIT, private: true, scripts: { serve: vue-cli-...
Rational Interger
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 ...
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 ...
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 ...
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 ...
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. /...
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 ...
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...
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 ...
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 ...
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 ...
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...
// 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....
/// Performs the text-to-speech operations: it takes a std::string as input and outputs the corresponding audio signal in the specified file. /// </summary> /// <param name="pStringToSay"> Text to ...
报错crashsender.exe is not found the specified path
IllegalStateException: The specified child already has a parent.我的博客中有文章讲解
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解决办法 Server Error in ‘/’ Application. The system cannot find the file specified Description: An unhandled exception occurred during the execution...
问题链接: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.