首先导入alibaba的fastJson包
后台:
String thirdPage1=prop.getProperty("thirdPage1");
String thirdPage2=prop.getProperty("thirdPage2");
Map<String,String>map=new HashMap<>();
map.put("thirdPage1", thirdPage1);
map.put("thirdPage2", thirdPage2);
String json=JSON.toJSONString(map);
pw.print(json);
前端:
<script type="text/javascript">
$(function(){
var lanaguage1=$('input:radio:checked').val();
$.ajax({
dataType:"json",
type:"post",
url : "LanguageServlet?page=firstPage",
success : function(result) {
$("#firstPage1").html(result.firstPage1);
$("#firstPage2").val()=result.firstPage2;
}
});
});
</script>