private FenleiBizIntf fenleiBizIntf = new FenleiBizImpl();
private Fenlei fenlei;
List<Fenlei> fenleilist = null;
private boolean message = false;
public boolean isMessage() {
return message;
}
public void setMessage(boolean message) {
this.message = message;
}
public List<Fenlei> getFenleilist() {
return fenleilist;
}
public void setFenleilist(List<Fenlei> fenleilist) {
this.fenleilist = fenleilist;
}
public Fenlei getFenlei() {
return fenlei;
}
public void setFenlei(Fenlei fenlei) {
this.fenlei = fenlei;
}
public String addFenleiAction()
{
message = fenleiBizIntf.addFenlei(fenlei);
fenleilist = fenleiBizIntf.getFenleiAll(null, null);
return SUCCESS;
}
页面中:
function ajaxAddFenlei()
{
var fenleiname = $('#fenleiname').val();
var fenleisupname = $('#fenleisupname').val();
$.ajax
(
{
url:,'addFenleiAction!addFenleiAction.action'
secureuri:false,//一般设置为false
dataType: 'json',//返回值类型 一般设置为json
data: "fenlei.name="+fenleiname+" &fenlei.supname="+fenleisupname,
success: function (data, status) //服务器成功响应处理函数
{
if(data.message==true)
{
alert("恭喜您,新增类别成功!");
$('#fenleiid').empty();
for(var i = 0,len = data.fenleilist.length; i<len; i++)
{
//alert(data.fenleilist[i].id+'-------');
//alert(data.fenleilist[i].name+'----');
if(i==len-1)
{
$('#fenleiid').append($("<option value='"+data.fenleilist[i].id+"' selected='selected'>"+data.fenleilist[i].name+"</option>"));
}
else
{
$('#fenleiid').append($("<option value='"+data.fenleilist[i].id+"'>"+data.fenleilist[i].name+"</option>"));
}
}
$('#fenleiid').append($("<option value=-1>新增类别</option>"));
closeDiv('aaaa');
}
},
error: function (data, status, e)//服务器响应失败处理函数
{
//alert(e);
}
}
)
}
执行时候页面是可以正常得到message数值和fenleilist数值。
---------------------------------------------------------------------------------------------------------------------------------
以下是无法取到值的情况:
Integer n ;
set .....
get ....
public String checkPersoncode()
{
String code = ServletActionContext.getRequest().getParameter("userPersoncode");
System.out.println(code);
n = userBiz.selectPersoncodeByCode(code);
return SUCCESS;
}
页面也是那样写的,但是弹出来的值始终未定义。
但是这样倒是可以的 如:
public String checkPersoncode()
{
ServletActionContext.getResponse().setCharacterEncoding("utf-8");
String code = ServletActionContext.getRequest().getParameter("userPersoncode");
System.out.println(code);
Integer n = userBiz.selectPersoncodeByCode(code);
System.out.println(n);
try {
ServletActionContext.getResponse().getWriter().print(n);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return NONE;
}
不得其解释啊!!!!