client客户表和order订单表是一对多的关系,现在client表中有 @OneToMany
@JoinColumn(name="client_id")
private List orderList;//客户订单
然后我怎么通过struts2把所有order之值带到jsp页面呢
struts2的ajax请求没用过。一直是自己写的工具类
public static String renderText(final T entity) {
try {
getHttpResponse().setContentType("text/plain;charset=UTF-8");
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(entity);
getHttpResponse().getWriter().write(json);
} catch (final IOException e) {
// LOGGER.error(e.getMessage(), e);
}
return null;
}
这是传对象到前台
传字符串是
public static String renderText(final String text) {
try {
getHttpResponse().setContentType("text/plain;charset=UTF-8");
getHttpResponse().getWriter().write(text);
} catch (final IOException e) {
// LOGGER.error(e.getMessage(), e);
}
return null;
}
你可以通过Struts对值栈的操作来实现,后台为actionContext.getContext().put()或者actionContext.getContext().getValueStack().push(),或者干脆一点用get/set方法也行
然后后台就可以这样写
public void editAjax() throws Exception {
User p = userService.getById(param);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(p);
AjaxUtil.renderText(json);
}
可以通过Struts对值栈的操作来实现