json传递

action中

public String alter() throws UnsupportedEncodingException{

boolean bool=lexiconService.UpdFile(param);
if(bool){
inputStream =new ByteArrayInputStream("修改成功!!!!".getBytes("utf-8"));
}else{
inputStream =new ByteArrayInputStream("修改失败!!!!".getBytes("utf-8"));
}

return "Alter";
}


struts2中

<action name="······_*" class="··" method="{1}">

   <result name="Alter" type="stream">
  <param name="contentType">text/html</param>
        <param name="inputName">inputStream</param>
</result>

</action>


jsp js中

function alterFilter() {
var contains=$("#···").val();
if($.trim(contains)==''){
alert("新的关键词不能为空!!!");

}else{
var r=confirm("是否修改关键字!!!");
if(r==true){
//window.location.href="classifyAction_addUI.action";
$.ajax({
type:"post",
url:"······_alter.action",
dataType:"text",
async: false,
data:$('#alterform').serialize(),
success:function (inputStream) {
if(inputStream=='修改成功!!!!'){
alert(inputStream);
window.location.href="classifyAction_listUI.action";
}else{
alert(inputStream+'请重试');
}
},
error:function(){
alert("失败");
return false;
}
});
}else{
······
}
}
}

你可能感兴趣的:(json)