ext代码:
效果:
//声明文本域,name为text,此name在后台提交时需要用到,必须写。表单提交到1.jsp
var field=new Ext.form.TextField({
fieldLabel:'fieldLabel',
name:'text',
allowBlank:false,
emptyText:'空',
maxLength:15,
minLength:5,
msgTarget:'under'
})
var form2=new Ext.form.FormPanel({
title:'form2',
frame:true,
items:[field],
url:'1.jsp',
buttons:[{
text:'提交',
handler:function(){
form2.getForm().submit({
success:function(form,action){
Ext.Msg.alert('消息',action.result.msg);
},
failure:function(){
Ext.Msg.alert('消息','失败');
}
});
}
}],
renderTo:'form2'
})
})
1.jsp后台处理代码
String text=request.getParameter("text");
System.out.println(text);
out.write("{success:true,msg:'你懂得'}");
效果:
![](https://img-my.csdn.net/uploads/201207/12/1342080460_3777.png)