struts2使用jsp和标签获取json格式的返回数据

时间:2023-03-08 16:35:59

struts2使用jsp和<s:property>标签获取json格式的返回数据

1、struts2的action中

return "success";

2、指向的返回页面success.jsp中的内容为:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%><%@ taglib prefix="s" uri="/struts-tags"%><s:property
value="jsonString" escape="false" /> 3、前端jquery的请求方式如下:
$.ajax({
url: _url,
type: 'post',
dataType: 'json',
success: function(data){ 此处返回的data即为json格式的数据