I ended up finding a way to bypass "JSON" from the Spring MVC portlet controller. Here is how I did it.
In my controller:
@ResourceMapping("ajaxTest")
public void ajaxHandler(ResourceRequest request, ResourceResponse response)
throws IOException {
OutputStream outStream = response.getPortletOutputStream();
StringBuffer buffer = new StringBuffer();
Map<String, String> testMap = new HashMap<String, String>();
testMap.put("foo", "bar");
String test = new JSONObject(testMap).toString();
buffer.append(test);
outStream.write(buffer.toString().getBytes());
}
In "view.jsp":
<portlet:resourceURL var="ajaxtest" id="ajaxTest"/>
<script type="text/javascript">
$.get('<%= ajaxtest %>', function(response) {
var json = eval('(' + response + ')');
});
</script>
@ResourceMapping JSON, org.json.JSONObject JSON toString() . @ResourceMapping URL. eval JSON Javascript , , . , JSON.