Is there a way to pass parameters from ModelAndView to a window.onload function in JavaScript within an HTML file?
Here is an example of how it can be done:
@RequestMapping(value = "/admin/printtext")
public ModelAndView printtext() {
ModelAndView modelAndView = new ModelAndView("printtext", "showBackLink", false);
String name = "name0";
modelAndView.addObject("name", name);
return modelAndView;
}
In your HTML file, you can use the following script to access the parameter:
<script type="text/javascript">
window.onload = function (${name}) {
document.write('text')
}
</script>