- 浏览: 117065 次
- 性别:
- 来自: 成都
文章分类
最新评论
警告信息:
struts.xml配置信息(部分)
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提交的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
请求页面后,大家很失望吧?警告依然存在。但是我们看一下警告信息。
警告信息:
没有在'/myNameSpace'的namespace中发现指定的action '/login.action'
毫无疑问,这里的警告和第一次的警告信息截然不同。我们现在存在命名空间,'/myNameSpace'能够被struts2检索到,并不是开始的''。那问题的关键在哪里呢?
在namespace中没有发现指定的action '/login.action' ???
我们来看一下struts.xml中的配置:
是的,我们'/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
请求页面时,我们发现不再有警告信息了。
如果你有足够细心,我想你应该可以彻底的明白为什么struts2会报警了吧?你也应该明白了使用struts2标签action中添加/线后请求反而报错的原因了。
警告: 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中的配置:
<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中添加/线后请求反而报错的原因了。
发表评论
-
struts2 token拦截器
2014-01-14 20:44 866之前struts2解决token必须在每个action配置 ... -
eclipse tomcat启动,内存溢出问题
2013-04-12 10:28 859在启动过程中出现内存溢出问题,抛出类似如下异常信息: java ... -
FreeMarker作为Struts2的视图
2012-07-27 17:09 724Struts使用FreeMarker作为其默认的模板技术,因此 ... -
spring security的标签库
2011-11-07 16:35 7539应用标签库:<%@ taglib prefix='sec ... -
STRUTS2 Convention零配置
2011-11-04 15:53 669从struts2.1开始,struts2不再推荐使用Codeb ... -
Hibernate - DetachedCriteria 的完整用法
2011-11-04 15:33 792Hibernate - DetachedCriteria 的完 ... -
Hibernate二级缓存及产品Oscache
2011-11-04 15:19 1954二级缓存也称进程级的缓存或SessionFactory级的缓存 ... -
struts2的struts.properties配置文件详解
2011-11-04 14:40 784struts.action.extensionThe U ... -
JPA @MappedSuperclass注解的使用说明
2011-10-31 17:51 856基于代码复用和模型分离的思想,在项目开发中使用JPA的@Map ... -
freemarker的国际化
2011-10-27 10:58 912起首在servlet中加上加载资料文件的代码 Local ... -
net.sf.json的使用
2011-10-26 17:26 2129需要jar包:ezmorph-1.0.6.jar,json-l ... -
FreeMarker设计指南
2011-10-18 17:57 729(1)模板 + 数据模型 = 输出 FreeMarke ... -
Freemarker中遍历List实例
2011-10-18 13:12 7660Freemarker中如何遍历List ... -
freemarker中使用struts2标签
2011-10-15 16:01 9421.将系统所需的标签库定义文件(也就是tld文件)复制到web ... -
Freemarker源码解析
2011-10-10 17:21 1036FreeMarker 自定义模版文 ... -
实体 Bean 注解
2011-10-06 15:36 1343一、 实体 Bean 每个持久化POJO类都是一个实体Bea ... -
struts2.0 标签+ftl标签
2011-10-05 14:58 895直接调用后台方法代码 <PRE class=ftl n ... -
Struts2使用 -- Convention插件
2011-10-04 11:04 767本文来自CSDN博客: http:/ ... -
struts2 validation中指定返回的result input
2011-10-04 09:23 869@InputConfig注解于方法 @InputConfig( ... -
Struts2日期格式
2011-09-30 10:48 787struts2 中的默认的日期输出并不符合我们的中文日常习惯。 ...
相关推荐
在初始化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...
问题链接: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.
Please see the actual settings later in the document for more details as to why ; we recommend these changes in PHP's behavior. ; display_errors ; Default Value: On ; Development Value: On ; ...