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

struts2 奇怪的Action警告

阅读更多

不知道大家有没有遇到在使用表单的时候,有时候会出一个莫名其妙的警告:

 

2008-1-6 21:14:47 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified action: '/LoginAction.action' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.

登录的时候,要表单提交到Action:LoginAction.action, 结果却出了这个警告,暂时没明白为什么,因为程序不影响正常使用。但总有解决的办法吧。

以下写法均会出这个警告

 

<s:form action="/LoginAction" method="post">
<s:form action="/LoginAction.action" method="post">
<s:form action="LoginAction.action" method="post">

 

正确的写法只有:

 

<s:form action="LoginAction" method="post">

 

如果有明白为什么的,希望能留个言。

分享到:
评论
11 楼 lalaeye 2010-02-09  
	<package name="json"[color=blue] namespace="jiaoye"[/color] extends="json-default">
		<action name="jsonPerson" class="mp.likeming.action.JSONPersonAction">
			<result type="json" />
		</action>
	</package>


<s:form action="/jsonPerson.action" namespace = "jiaoye">
    <p>姓名: <s:textfield name="person.name" /></p>
    <p>性别: <s:radio list="#{'1':'男', '0':'女'}" name="person.sex" value="0" /></p>
    <p>年龄: <s:textfield name="person.age" /></p>
    <p><s:submit value="提交" /></p>
</s:form>



10 楼 ponlya 2010-01-16  
不知LZ这个问题解决了没有。如果没有,建设看一下javasunnyboy的文章:http://javasunnyboy.iteye.com/blog/254753  分析的很详细。
9 楼 younglibin 2009-10-22  
果然美女来看的人多。大家在提价时看看页面源文件就好了!这就是struts2 标签强大之处!人家会自己加,不用老是忘了加“/”!
8 楼 seahb 2009-08-05  
There is no Action mapped for namespace / and action name jsonPerson
这个问题我遇到过 可能因为你jsonplugin-0.32.jar这个jar包漏了 因为你继承了json-default
7 楼 jalx 2009-02-26  
提交表单后的错误问题解决了, 原来是看的哪个教程写错误了...
让我把JSON Plugin包放在WEB-INF下, 我当时很是奇怪. 试到现在, 不得不怀疑是否教程有误.
正确的应是放入lib下.

只是表单本身问题依然存在, 虽然调整为了下面写法:
<s:form action="/jsonPerson.action">
    <p>姓名: <s:textfield name="person.name" /></p>
    <p>性别: <s:radio list="#{'1':'男', '0':'女'}" name="person.sex" value="0" /></p>
    <p>年龄: <s:textfield name="person.age" /></p>
    <p><s:submit value="提交" /></p>
</s:form>

访问所在页面还是警告:
引用

2009-2-26 16:45:59 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: '/jsonPerson.action' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
6 楼 jalx 2009-02-26  
我刚刚也遇到这个问题了, 找了半天没解决...

Struts 2.1.6下, 你描述的正确写法是对的. 我一直都是这样写的, 包括前段时间学习Struts 2.0.*时.

我的问题出在添加JSON Plugin插件后, 相关配置如下:

1. struts.xml

	<package name="json" extends="json-default">
		<action name="jsonPerson" class="mp.likeming.action.JSONPersonAction">
			<result type="json" />
		</action>
	</package>


2. 表单

<s:form action="jsonPerson">
    <p>姓名: <s:textfield name="person.name" /></p>
    <p>性别: <s:radio list="#{'1':'男', '0':'女'}" name="person.sex" value="0" /></p>
    <p>年龄: <s:textfield name="person.age" /></p>
    <p><s:submit value="提交" /></p>
</s:form>


如此的话, 只要访问表单所在页面就会出现警告:

引用

2009-2-26 15:57:11 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: 'jsonPerson' in namespace: ''. Form action defaulting to 'action' attribute's literal value.


查看该页面源代码:

<form method="post" action="jsonPerson" id="jsonPerson">
    <p>姓名: <input type="text" id="jsonPerson_person_name" value="" name="person.name"/></p>
    <p>性别: <input type="radio" value="1" id="jsonPerson_person_sex1" name="person.sex"/><label for="jsonPerson_person_sex1">男</label>
<input type="radio" value="0" checked="checked" id="jsonPerson_person_sex0" name="person.sex"/><label for="jsonPerson_person_sex0">女</label>
</p>
    <p>年龄: <input type="text" id="jsonPerson_person_age" value="" name="person.age"/></p>
    <p><input type="submit" value="提交" id="jsonPerson_0"/>
</p>
</form>


提交表单后错误:

引用

2009-2-26 15:59:31 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find action or result
There is no Action mapped for namespace / and action name jsonPerson. - [unknown location]


这里可以明确的是, action继承json-default后, 表单中的action名称就不会被自动解析为正常action路径了. 关于JSON Plugin不熟, 第一次使用. 是不是哪里配置有问题, 还望知道的朋友指正!
5 楼 reinhardt49 2008-01-24  
把'/LoginAction.action' 中的/去除
4 楼 reinhardt49 2008-01-24  
把'/LoginAction.action' 中的/去除
3 楼 reinhardt49 2008-01-24  
把'/LoginAction.action' 中的 '/' 去掉
2 楼 kyo100900 2008-01-09  
请注意看: <s:form action="LoginAction" method="post"> 
用到了 struts2 自带的标签, Struts2标签会在提交时,加上extension
1 楼 dingdangxiaoma 2008-01-08  
您好,您所说的这个是有问题的呢.我已经试过了啊.不行的.

引用
struts.properties   struts.action.extension=action


如果,像您那样写提交的话,会把它当作一个servlet 来进行处理,而不是当作一个.action 来进行处理,所以那样做是不对的呢.
在java 中,一般的没有后缀的文件,也就是Servlet 吧.而且,这样写就把,它们混在一起了,也不利于维护啊.呵.

相关推荐

    Struts 2实战 struts2 in Action

    根据提供的文件信息,我们可以从《Struts 2实战 Struts2 in Action》这一书籍中提炼出与Struts 2框架相关的多个重要知识点。Struts 2是一个基于Java的开源Web应用框架,它继承了Struts 1的优点并进行了大量的改进和...

    Struts2实战(Struts2 In Action中文版)

    **Struts2实战——《Struts2 In Action中文版》** 《Struts2 In Action》是一本专为Java开发者设计的实战指南,旨在深入解析Struts2框架的使用与实践。Struts2作为一款强大的MVC(Model-View-Controller)框架,极...

    Struts2 in action(struts2实战)

    作为一个基于Action和基于拦截器的框架,Struts2提供了丰富的功能,使得开发者能够构建可维护、可扩展的Web应用。下面我们将深入探讨Struts2的主要特性、工作原理以及如何在实际开发中运用。 1. **核心概念**: - ...

    Struts 2实战 Struts 2 in action 的中文版

    根据提供的信息,我们可以推断出这是一本关于Struts 2框架的书籍——《Struts 2实战 Struts 2 in action 的中文版》。本书主要介绍了Struts 2框架的相关概念、工作原理以及实际应用案例等内容。接下来,我们将根据...

    Struts2 in action中文版+配套源代码

    "Struts2 in Action" 是一本深入探讨Struts2框架的专业书籍,旨在帮助开发者掌握这一框架的核心概念和实践技巧。这本书的中文版不仅提供了理论知识,还附带有配套的源代码,方便读者进行实践操作,加深理解。 ...

    Struts2 in action

    当用户通过浏览器发送请求时,Struts2会将请求转发给相应的Action处理。 - **执行流程**: - 用户发起HTTP请求。 - 请求被Struts2的前端控制器(FilterDispatcher)拦截。 - FilterDispatcher根据配置找到对应的...

    struts2 使用action属性接收中文参数(post提交)

    在处理用户请求时,Struts2允许开发者通过Action类来接收和处理参数,包括中文参数。当我们需要通过POST方法提交包含中文字符的数据时,可能会遇到编码问题,因为HTTP请求默认使用的是ASCII编码,而中文字符需要UTF-...

    Struts2 in action 中文版

    《Struts2 in Action》中文版是一本深入探讨Struts2框架的专业书籍,该书不仅提供了详尽的理论知识,还包含了大量的实战案例,对于希望掌握Struts2框架的开发者来说,是一本不可或缺的参考书。 ### Struts2框架概览...

    struts2 in action 源码

    struts2 in action 源码

    Struts2 in action 中文版.pdf

    《Struts2 in Action》是一本深入探讨Struts2框架的权威著作,中文版的发布使得国内开发者能够更方便地理解和应用这一强大的Java Web开发框架。Struts2是Apache软件基金会旗下的一个开源项目,它是MVC(Model-View-...

    struts2 in action 中文版 英文版 源代码 合集

    《Struts2 in Action》是一本深入介绍该框架的专业书籍,无论是中文版还是英文版,都为读者提供了全面理解和实践Struts2的知识。 中文版的《Struts2 in Action》为中文阅读者提供了方便,使得理解复杂的框架概念变...

    Struts2中Action接收参数的方法

    Struts2 中 Action 接收参数的方法 Struts2 框架中,Action 组件可以通过多种方式接收参数,这些方式包括使用 Action 的属性、使用 DomainModel 和使用 ModelDriven。下面将详细介绍这些方法: 使用 Action 的属性...

    struts2 in Action

    如果你想自学struts2,此文档是很好的自学宝典,经典struts2 in Action,能帮你建立整体的struts2思想,你还在犹豫什么

    struts 2 action 动态调用

    ### Struts 2 Action 动态方法调用详解 #### 一、引言 在Struts 2框架中,Action动态方法调用是一项非常实用的功能。它允许开发者在一个Action类中定义多个处理方法,而不仅仅局限于传统的`execute()`方法。这种...

    struts2中警告消息问题的解决方法

    - **Action或结果配置**:Struts2 Action类中的属性未在配置文件中声明,或者结果配置中引用了不存在的属性,也会导致这类警告。 2. **解决方法**: - **检查配置文件**:确保所有配置文件中的属性都已正确设置,...

    struts2.0之action

    尽管Struts 2.0的Action可以不依赖任何特定类或接口,但通常为了利用框架提供的便利性,开发者会选择继承`com.opensymphony.xwork2.ActionSupport`类。`ActionSupport`提供了诸如国际化、错误处理和验证等基础功能,...

    struts2 in action

    struts2 in actionstruts2 in actionstruts2 in actionstruts2 in actionstruts2 in actionstruts2 in actionstruts2 in action

    struts2 action 返回json方法(一)源码

    Action是Struts2的核心组件,用于处理用户的请求,并返回相应的结果。在现代Web应用中,数据通常以JSON(JavaScript Object Notation)格式在客户端和服务器之间交换,因为JSON具有轻量级、易于解析的特性。本篇将...

Global site tag (gtag.js) - Google Analytics