我是春天的新人,我有这个控制器:
@ModelAttribute("mediaJson")
@Transactional(value=CLIENT_TRANSACTION_MANAGER, readOnly=true)
public String getPlayerMedia(@PathVariable String playerHash, @PathVariable String mediaId) throws ServiceException, JsonProcessingException {
PlayerController playerController = new PlayerController();
playerController = authenticationService.authenticatePlayerHash(playerHash);
PlayerMediaDTO media = playerService.getPlayerMedia(playerController, mediaId, null, null, null);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(media);
return json;
}
@ModelAttribute("attrs")
public ViewAttributes getProxyPath(@ModelAttribute("mediaJson") String jsonString) {
ViewAttributes attr = new ViewAttributes();
attr.setProxy(proxy);
attr.setDescription(jsonString);
return attr;
}
//View
@RequestMapping(value="/index/{playerHash}/{mediaId}", method=RequestMethod.GET)
public String loadMediaJson(@PathVariable String playerHash, @PathVariable String mediaId, ModelMap model) {
return "index";
}
请注意,我想访问attrs属性的mediaJson属性来填充它。我怎样才能做到这一点? 我在这里尝试过,但似乎只有在setDescription行上放置一个调试断点时才会起作用(可能是因为同步)。
任何人都可以帮我吗?