`
m635674608
  • 浏览: 5028949 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Form action defaulting to 'action' attribute's literal value .

 
阅读更多

在使用<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。

转载请注明 historycreator.com

分享到:
评论

相关推荐

    tomcat报错Unable to find 'struts multipart saveDir解决

    标题中的“tomcat报错Unable to find 'struts multipart saveDir'”是一个常见的问题,通常出现在使用Apache Struts框架,并且在处理multipart/form-data类型的请求时。这种类型的请求通常用于上传文件,而`saveDir`...

    报错 代码 经验

    Form action defaulting to 'action' attribute's literal value. ``` **知识点解释:** 1. **问题描述:** - 在此例中,Struts框架未能找到指定的`fileUpLoad.action`配置。 - 这可能是因为配置文件中没有为该...

    串口通讯控件

    - Added defaulting mechanism for handshake thresholds to avoid errors due to fixed defaults conflicting with driver queue size defaults. - Changed default for sendTimeoutMultiplier for not NT-...

    lammps导热系数计算方法,导热系数的计算,Unix_Linux

    19或许各位有疑问,诶,窝明明固体物理和热统学过啊,如果不计入格点间的非简谐相互作用(即关于位置变化量的3阶项及以上),非谐效应中的热膨胀和热传导是不存在的由于核心思路是通过热流和温度梯度在某段范围内...

    Java邮件开发Fundamentals of the JavaMail API

    SMTP server will relay the message on to the SMTP server of the recipient(s) to eventually be acquired by the user(s) through POP or IMAP. This does not require your SMTP server to be an open relay,...

    archetype-catalog.xml

    Idea创建的Maven项目出现警告:No archetype found in remote catalog. Defaulting to internal catalog所需要的文件

    chromeDriver2.43版本安装包

    chrome_driver_path = "path/to/your/chromedriver" # 创建ChromeDriver对象 driver = webdriver.Chrome(executable_path=chrome_driver_path) ``` 4. 操作浏览器:现在你可以使用`driver`对象来控制Chrome浏览器了...

    Simplifying [removed] Writing Modern JavaScript with ES5, ES6, and Beyond pdf

    Select collections with clear goals instead of defaulting to objects or arrays. See how to simplify iterations from complex loops to single line array methods. Master techniques for writing flexible ...

    netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar

    java运行依赖jar包

    JAIN实现简单点对点聊天软件 sip聊天软件 JAIN-sip聊天软件

    eantruntime' was not set, defaulting to build.sysclasspath=last; set to false fo r repeatable builds BUILD SUCCESSFUL Total time: 0 seconds 3.执行命令: java -jar textclient.jar &lt;username&gt; &lt;port&gt; ...

    EC.zip_eC_inheritance

    The design discussions concentrate on how to choose between different approaches to accomplishing something in C++. How do you choose between inheritance and templates? Between templates and generic ...

    slf4j-nop-1.6.6.jar

    SLF4J: Failed to load class "org.slf4j.impl....SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

    ModernGadgets_1.6.3.rmskin

    ModernGadgets is a set of sleek, minimalist, information-dense gadgets that are designed to fit right into your modern desktop....- Allows process filtering, defaulting to all system-re

    ViewPager 放大缩小左右移动

    * True to smoothly scroll to the new item, false to transition * immediately */ public void setCurrentItem(int item, boolean smoothScroll) { mPopulatePending = false; setCurrentItemInternal...

    五子棋 源码

    Defaulting to 0x0502 (Windows Server 2003) 正在编译... SetupDlg.cpp RecordDlg.cpp PenteDlg.cpp c:\documents and settings\kjl801\桌面\vc.net 五子棋源码\pentedlg.cpp(45) : warning C4101: 'szVer' : ...

    Android代码-Prop-Editor

    Clicking 'Open File' button opens a [text box] file dialog, defaulting to the sdcard); enter the name of a build.prop type file on the sdcard. (cp /system/build.prop /sdcard/build.prop first) Opening ...

    SLF4J日志报错解决办法

    处理slf4j日志使用的基本错误,导入三个包,分别是slf4j-impl,slf4j-api和slf4j-log4j12

    WSDD + TOMCAT 一键部署Webservices

    [javac] D:\java\wsdd\build.xml:16: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 5 source files to D:\java\...

    TongWeb上应用移植常见问题.doc

    在运维TongWeb应用的过程中,可能会遇到一些移植问题,尤其是从其他环境如Tomcat迁移到TongWeb时。本文将详细解析三个主要问题及其解决方案,包括JPA冲突、validation问题和annotation扫描异常。...

    build-custom-rpm:迪斯科里

    build-custom-rpm/hhvm (r2dev)$ make ... defaulting to Fedora release 20 (Heisenbug)Evia RPM Build RootName:hhvmSummary:HipHop VM (HHVM) is a virtual machine for executing programs written in PHPPackag

Global site tag (gtag.js) - Google Analytics