一个完整的json返回

用了titles框架,故多了一个titles的配置

jsp:

function onOk(e) {

     $.ajax({

           cache: true,

            type: "POST",

            url:"<%=path%>/productLabel/productLabelEdit!save.action",

            data:$('#form1').serialize(),

            async: false,

            error: function (data) {

                mini.alert(data.msg);

            },

          

            success: function(data) {

                mini.alert(data.msg,'提示',function(){

                   CloseWindow("save");

                });

            }

           

        });

    

}

 

struts:

<action name="productLabelEdit" class="productLabelAction">

     <result type="tiles">/productLabel/productLabelEdit.tiles</result>

     <result name="jsonMap" type="json">

<param name="root">jsonMap</param>

</result>

     </action>

 

titles: <definition name="/productLabel/productLabelEdit.tiles" extends="contentLayout">

        <put-attribute name="body" value="/jsp/product/productLabelEdit.jsp"/>

    </definition>

action:

public String save() throws RollbackableException {

try {

String tagName = request.getParameter("tagName");

WelProductTag bean = new WelProductTag();

bean.setTagName(tagName);

bean.setTagDesc("1");

if (StringUtils.isNotBlank(tagName)) {

iProductLabelService.saveOrUpdate(bean);

jsonMap.put("success", true);

jsonMap.put("msg", "增加成功!");

OpeLog opeLog=new OpeLog();

//新增操作

opeLog.setOperType("insert");

//操作时间

opeLog.setOperDatetime(new Date());

//操作表

opeLog.setOperTableName("WEL_PRODUCT_TAG");

this.iLogService.insertLog(opeLog);

}else{

jsonMap.put("success", false);

jsonMap.put("msg", "增加失败,请稍后重试!");

}

} catch (Exception e) {

e.printStackTrace();

jsonMap.put("success", false);

jsonMap.put("msg", "保存失败,请稍后重试!");

}

return JSON_MAP;

}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值