Http://www.iteye.com/topic/149652
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + "://"
+ Request. getservername () + ":" + request. getserverport ()
+ Path + "/";
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<Title> simple form example </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<LINK rel = "stylesheet" type = "text/CSS" href = "CSS/ext-all.css">
</Head>
<Body>
<SCRIPT type = "text/JavaScript" src = "JS/ext-base.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "JS/ext-all.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "JS/ext-lang-zh_CN.js"> </SCRIPT>
<SCRIPT>
Ext. quicktips. INIT ();
Ext. Form. Field. Prototype. msgtarget = 'day ';
VaR simpleform = new Ext. formpanel ({
Labelalign: 'left ',
Title: 'form example ',
Buttonalign: 'right ',
Bodystyle: 'padding: 5px ',
Width: 600,
Frame: True,
Labelwidth: 45,
Waitmsgtarget: True,
Items :[{
Xtype: 'tabpanel ',
Plain: True,
Activetab: 0,
Height: 235,
Ults: {bodystyle: 'padding: 10px '},
Reader: New Ext. Data. jsonreader (
{
Successproperty: 'success ',
Root: 'data'
},
[
{Name: 'name', mapping: 'name'}, // custom mapping
]
),
Items :[{
Title: 'properties ',
Layout: 'column',/** layout: 'form '**/
/** Defaults: {width: 230 },
Defaulttype: 'textfield ',**/
Border: false,
Labelseparator :':',
Items :[{
Columnwidth:. 3,
Layout: 'form ',
Border: false,
Items :[{
ID: 'name ',
Xtype: 'textfield ',
Fieldlabel: 'name ',
Name: 'name ',
Anchor: '000000'
}]
},{
Columnwidth:. 3,
Layout: 'form ',
Border: false,
Items :[{
ID: 'Password ',
Xtype: 'textfield ',
Inputtype: 'Password ',
Fieldlabel: 'Password ',
Name: 'Password ',
Anchor: '000000'
}]
},{
Columnwidth:. 4,
Layout: 'form ',
Border: false,
Items :[{
}]
}
]
},{
Title: 'digit and time letter ',
Layout: 'form ',
Defaults: {width: 230 },
Defaulttype: 'textfield ',
Items :[{
Xtype: 'numberfield ',
Fieldlabel: 'number ',
Name: 'number'
},{
Xtype: 'timefield ',
Fieldlabel: 'time ',
Name: 'time'
},{
Fieldlabel: 'Letters only ',
Name: 'Char ',
Vtype: 'alpha'
}]
}
});
Simpleform. Render (document. Body );
Simpleform. Load ({URL: 'test. jsp ', method: 'post', Params: "id = 1 "});
</SCRIPT>
</Body>
</Html>
Test. jsp:
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
<% @ Page import = "java.net. urldecoder" %>
<% @ Page import = "com. Ext. util. *" %>
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + "://"
+ Request. getservername () + ":" + request. getserverport ()
+ Path + "/";
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<Title> my JSP 'index. jsp 'starting page </title>
<Meta http-equiv = "Pragma" content = "no-Cache">
<Meta http-equiv = "cache-control" content = "no-Cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "Description" content = "this is my page">
</Head>
<Body>
<%
String id = request. getparameter ("ID ");
String name = "123 ";
String Password = "123"
System. Out. println ("ID =" + id );
Try {
// String JSON = "{/" success/": True,/" Data /":[";
// JSON + = "{/" name/":/" "+ name +"/"}"; //, {/"password /": "+"/"" + password + "/"}
String JSON = "{success: True, data :";
JSON + = "{Name: '" + name + "'}";
JSON + = "}";
Response. getwriter (). Write (JSON );
Response. getwriter (). Flush ();
System. Out. println (JSON );
} Catch (exception e ){}
%>
</Body>
</Html>