我有一个表单,如果我提交它,那么我希望从我的 json 响应中在同一页面中打印成功消息。
我从 json 响应中获得了许多值,但我只想要在我的 java 操作中定义的名为“消息”的变量。
格式化的json响应是这样的
`{"errmsg":null,"jsonModel":null,"message":"Succussfuyly completed the task","model":
{"createdDate":null,"createrId":null,"id":null,"themeCaption":null,"themeName":null,
"themeScreenshot":null,"updateId":null,"updatedDate":null},"oper":null,"theme":{"createdDate":null,
"createrId":null,"id":null,"themeCaption":null,"themeName":null,"themeScreenshot":null,
"updateId":null,"updatedDate":null},"themeScreenshot":null}`
从这个响应中,我只想在我的 jsp 页面中打印消息变量。从我下面的 jquery 代码中,所有值都打印在我的 jsp 页面中。但我只想要消息变量。
索引.jsp
<script type="text/javascript">
$(document).ready( function() {
$.subscribe('handleJsonResult', function(event,data) {
$('#result').html("<div id='languagesList'> <s:property value="Message"/> </div>"+'' + data.Message + '');
var list = $('#languagesList');
$.each(event.originalEvent.data, function(index, value) {
list.append('<h1>'+value+'</h1>\n');
});
});
});
</script>
</head>
<body>
<img id="indicator" src="${pageContext.request.contextPath}/images/others/ajax-loader.gif" alt="Loading..." style="display:none"/>
<s:form action="updatethemeimageform" method="post" enctype="multipart/form-data" id="remoteform" theme="simple" >
<s:hidden value="%{#parameters.themeid}" name="themId"/>
<s:file name="themeScreenshot" label="Theme Screenshot" />
<sj:a button="true" id="btnsid" buttonIcon="ui-icon-gear" dataType="json" indicator="indicator" onSuccessTopics="handleJsonResult"
formIds="remoteform" targets="result" >Submit This Form</sj:a>
</s:form>
<sj:div id="result" >
Json Result will come here
</sj:div>
`-----------
---------------
private String Message;
public String updateThemesImage(){
setMessage("Succussfuyly completed the task");
return SUCCESS;
}
------------
-----------
With getter & setters`
从我上面的 jquery 函数我得到这样的输出 请帮我解决这个问题