I am using spring mvc controller. Inside the controller, I put some value to say a line inside the model. Now I would like to get this value or just say that print this value inside javascript. How can I do it? Here is my controller class. I am adding a “movie” as a key. Now I want to display this movie name inside a java script (not inside a JSP. However inside JavaScript)
@Controller @RequestMapping("/movie") public class MovieController { @RequestMapping(value="/{name}", method = RequestMethod.GET) public String getMovie(@PathVariable String name, ModelMap model) { model.addAttribute("movie", name); return "list"; } }
here is my jsp
<html> <head> //I want to print movie name inside java script not inside jSP body tag. <script type="text/javascript"> var movie_name = ${movie}; alert("movies name"+ movie_name); </script> </head> <body> <h3>Movie Name : ${movie}</h3>//When i print here its working fine. </body> </html>
javascript jquery spring spring-mvc jsp
Dheeraj varne
source share