Этот вопрос работал для меня.
В основном, контроллер
@Controller
@RequestMapping("VIEW") // VIEW mapping (as opposed to EDIT)
public class MyPortlet {
@RenderMapping
public String handleRenderRequest(RenderRequest request, RenderResponse response) {
return "defaultRender";
}
@ResourceMapping("myURL")
public void handleMyResource(ResourceRequest request, ResourceResponse response) {
OutputStream outStream;
try {
outStream = response.getPortletOutputStream();
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(outStream, "Hello world!");
} catch (IOException ex) {
// TODO : Do something with errors.
}
}
}
и JSP:
<portlet:resourceURL id="myURL" var="myURL"/>
<script type="text/javascript">
var urlink = "<%= myURL %>";
$.ajax({
url: urlink,
cache: false,
type: "POST",
success: function(jsondata) {
console.log(jsondata);
}
});
</script>