ajax
var url = '/itsm/contract/contract!deleteShopItemById.action';
var shopItemId= selectRows[x].data.id;
$j.ajax({
url:url,
cache:false,
data:{
shopItemId: shopItemId
},
type:'post',
async:false,
success:function(a){
var data = eval('('+a+')');
console.log(data);
if(data.code == 200){
Ext.Msg.alert("提示",data.msg);
jsonstore_cg.remove(selectRows[x]);
} else {
Ext.Msg.alert("提示","删除失败!");
}
}
});
struts2
private String[] shopItemId; public String[] getShopItemId() {
return shopItemId;
} public void setShopItemId(String[] shopItemId) {
this.shopItemId = shopItemId;
} public String deleteShopItemById(){
ContractCmdbSupport ccs = new ContractCmdbSupport();
ccs.deleteInstanceByIds(shopItemId, true);
String response="{code:200,msg:'删除成功!'}";
responseStr(response);
return NONE;
} public HttpServletResponse getResponse() {
return ServletActionContext.getResponse();
} public void responseStr(String message){
getResponse().setContentType("text/html; charset=UTF-8");
try {
getResponse().getWriter().println(message);
getResponse().getWriter().flush();
} catch (IOException e) {
logger.error("action向页面传输json数据时发生错误。", e);
}
}