I am using spring 3 MVC and i have below classes.
External system would call my application using below URL:
http://somehost/root/param1/param2/param3
I have a spring MVC controller method as below:
public ModelAndView showPage(@PathVariable("param1") String paramOne, @PathVariable("param2") String paramTwo, @PathVariable("param3") String paramThree, HttpServletResponse response) {
SomeModel model = new SomeModel(paramOne, paramTwo, paramThree);
return new ModelAndView("SomeJsp", "model", model);
}
SomeModel.java
public class SomeModel{
private String paramOne;
private String paramTwo;
private String paramThree;
//constructor
//setters and getters
}
SomeJsp.jsp
//In this Jsp i have a div with few elements. Div is not visible by default.
//This jsp has externalJavascript included.
//I enable div and set the data into div elements using jquery.
<script src="<c:url value="/resources/js/extjs.js" />" type="text/javascript"></script>
externalJs.js
$(document).ready(function() {
//Here i need the model returned using ModelAndView
//I can get data from model and set into div elements.
});
In external java script file, is it possible to get the model content? If possible, how can i do that?
Thanks!
<script type="text/javascript">var myVar = "${model.paramOne}";</script>
– Bedspread