<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>form</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var form = new Ext.form.FormPanel({
labelAlign: 'right',
title: 'form',
labelWidth: 50,
frame:true,
fileUpload: true,
url: 'form2.jsp',
width: 280,
items: [{
xtype: 'textfield',
fieldLabel: '文本框',
name: 'file',
inputType: 'file'
}],
buttons: [{
text: '按钮',
handler: function() {
form.getForm().submit({
success: function(form, action){
Ext.Msg.alert('信息', action.result.msg);
},
failure: function(){
Ext.Msg.alert('错误', '失败');
}
});
}
}]
});
form.render("form");
});
</script>
</head>
<body>
<script type="text/javascript" src="../examples.js"></script>
<div id="form" style="margin:100px;"></div>
</body>
</html>
对应的form2.jsp为,设置了response.setContentType("text/html;charset=UTF-8");才兼容火狐与iE
<%@ page contentType="text/html;charset=utf-8"%> <% request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); String text = request.getParameter("text"); System.out.println(text); response.setContentType("text/html;charset=UTF-8"); response.getWriter().print("{success:true,msg:'成功'}"); %>