- 注册时间
- 2013-4-17
- 最后登录
- 2013-5-22
- 阅读权限
- 10
- 积分
- 59
- 精华
- 0
- 帖子
- 13
|
本帖最后由 hyyy 于 2013-4-26 11:14 编辑
针对问题2:
由于struts2在页面表单展示数据时html元素的name属性为XXX.XXX的形式,
a.jsp页面代码如下:(查看源代码后的文本)- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
- <link href="../../miniui/demo/demo.css" rel="stylesheet" type="text/css" />
- <script src="../../miniui/scripts/boot.js" type="text/javascript"></script>
-
- <style type="text/css">
- html, body
- {
- font-size:12px;
- padding:0;
- margin:0;
- border:0;
- height:100%;
- overflow:hidden;
- }
-
- .txt{
- color:#005aa7;
- border-bottom:1px solid #005aa7; /* 下划线效果 */
- border-top:0px;
- border-left:0px;
- border-right:0px;
- background-color:transparent; /* 背景色透明 */
- }
-
- </style>
-
- </head>
-
- <body>
- <form id="form1" name="form1" method="post" action="saveCaseCk.action">
- <fieldset style="border:solid 1px #aaa;padding:3px;">
- <legend >基本信息</legend>
- <div style="padding:5px;text-align:center;"><!-- div中table居中 -->
- <table border="0" style="margin:0 auto;width:800;text-align:left">
- <tr><td>委托时间</td><td><input name="reg.consignTime" class="txt" value="2012-11-02 08:03:03" style="width:125px"/></td>
- <td>委托机构</td><td ><input type="text" name="reg.consignUnit" value="DD" id="reg_consignUnit" class="txt" style="width:40px;"/></td>
- <td>报案号</td><td><input type="text" name="reg.caseId" value="4176120" id="reg_caseId" class="txt" style="width:140px;"/></td>
- <td>流水号</td><td><input type="text" name="reg.regid" value="LS201211306071DD" readonly="readonly" id="reg_regid" class="txt" style="width:120px;"/></td></tr>
-
- <tr><td>事故经过</td><td colspan="7"><input type="text" name="reg.casing" value="被刮" id="reg_casing" class="txt" style="width:700px"/></td></tr>
- <tr><td>备注(调度)</td><td colspan="7"><input type="text" name="reg.memo" value="[车牌:粤B0]最近一次在2012-11-02 08:01:24.0有出险记录;_" id="reg_memo" class="txt" style="width:700px"/></td></tr>
- </table>
- </div>
- </fieldset>
-
- <div style="text-align:center;padding:10px;">
- <a class="mini-button" onclick="onsave" style="width:60px;margin-right:20px;">确定</a>
- <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
- </div>
- </form>
- <script type="text/javascript">
- mini.parse();
- var form = new mini.Form("form1");
-
- function onsave(e){
- var o = form.getData();
- var json = mini.encode([o]);
- alert(json);
-
- $.ajax({
- url: "../cx/ckSvaeCase.action",
- data: { data: json },
- cache: false,
- success: function (text) {
- CloseWindow("save");
- },
- error: function (jqXHR, textStatus, errorThrown) {
- alert(jqXHR.responseText);
- CloseWindow();
- }
- });
-
- }
- function onCancel(e) {
- CloseWindow("cancel");
- }
- function CloseWindow(action) {
- if (action == "close" && form.isChanged()) {
- if (confirm("数据被修改了,是否先保存?")) {
- return false;
- }
- }
- if (window.CloseOwnerWindow){
- return window.CloseOwnerWindow(action);
- }else{
- window.close();
- }
- }
-
-
- </script>
- </body>
- </html>
复制代码 执行onsave中显示json为[{}],即空json串,这是为何?是form写的有问题,还是取的方法有问题?
|
|