当我构建一个模块/组件时,需要向ActionResult传递什么才能在Ajax调用中接收正确的HTTPServletRequest?
例如(在我的jsp中):
var location = '${currentNode.path}.sqlPaging.do';
$.post(location, function(data) {
temp=data;
alert(data.info);
$('#result').html(data);
});进一步的信息(这是我的班级):
@Override
public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource,
JCRSessionWrapper session, Map<String, List<String>> parameters, URLResolver urlResolver)
throws Exception {
JSONObject json = new JSONObject();
json.put("info",3.14);
ActionResult result = new ActionResult(HttpServletResponse.SC_OK, null, json);
result.setJson(json);
return result;
}使用的包: javax.servlet.http org.jahia.bin.ActionResult org.json.JSONObject
发布于 2013-08-26 15:14:26
这就是问题所在。我需要在Ajax调用中有JSON (以引号表示),我需要调用"data.info“。
var location = '${currentNode.path}.sqlPaging.do';
$.post(location, function(data) {
temp=data;
alert(data.info);
$('#result').html(data);
},"json");THanks qlamerand
发布于 2014-01-08 10:14:29
处理ajax调用的另一个解决方案是注册自己的spring控制器。Jahia web应用程序预装了spring核心、spring、spring和所有你可能需要的东西。
您需要在application-context.xml文件中进行一些配置。
您甚至可以使用注释ex.@Controller作为老板,而不是在xml文件中注册jahia控制器。
http://fruzenshtein.com/spring-mvc-ajax-jquery/
干杯!
https://stackoverflow.com/questions/18443572
复制相似问题