日期:2014-05-20  浏览次数:20685 次

struts2中用action传递参数出现警告,怎么解决?(struts2的菜鸟)
1、警告如下:

2013-2-13 10:28:58 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Parameter [age] is not on the excludeParams list of patterns and will be appended to action!
2013-2-13 10:28:58 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: Parameter [name] is not on the excludeParams list of patterns and will be appended to action!
name=aaa
age=8

2、struts.xml中的action
 
<action name="user" class="struts2.user.user">
            <result>
                /addUser.jsp
            </result>
        </action>

3、user类

package struts2.user;

import com.opensymphony.xwork2.ActionSupport;

public class user extends ActionSupport{
private String name;
private int age;
public String add(){
System.out.println("name="+name);
System.out.println("age="+age);
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}

}


4、跳转链接

<a href="user/user!add?name=aaa&age=8">添加用户</a>



诸位帮帮忙啊,真的不会弄,好多天了,还是这样。。。
 
java? struts action

------解决方案--------------------
在struts.xml配置中添加以下配置
<constant name="struts.devMode" value="false" />
关闭开发模式,即
<struts>
<constant name="struts.devMode" value="false" />
...
<package name="yourpackagename" extends="struts-default">
...
</package>
</struts>
至于为什么会出现这样的警告,我也没找到具体的解析
------解决方案--------------------
楼主,这警告信息主要是日志处理的。Struts2默认是采用LoggerFactory(com.opensymphony.xwork2.util.logging.LoggerFactory)做日志处理的,其中有2个主要处理类可以选择:两种选择:Apache的CommonLogging 和JdkLoggerFactory

使用Struts2自带的日志处理类是需要配置的,你可以参考下:http://hi.baidu.com/sunny_sl/item/da263b76e4ee703870442364

在开发中一般不会使用Struts2自带的日志处理类,一般都会使用第三方提供的日志处理类,如:log4j或slf4j等,具体的楼主可以百度或google,推荐你去看看log4j的使用
其实楼主如果只是做练习项目的话,这个警告不会影响你功能的实现。如果你不想老看到这个警告信息的话,可以在struts的下载包中搜一个叫log4j.properties的文件放入src目录下就行了(你jar包完整的前提下:需要一个log4j-xx-xx.jar)