Reputation: 91
How to load content into a textarea using spring mvc, for example - from database ?
Upvotes: 0
Views: 7091
Reputation: 120811
Write an MVC Controller with an method that returns a ModelAndView with an attribute that is contains the content and write a JSP Pages (the view from ModelAndView) that uses creates a text area with the attribute from the Modell
@Controller
@RequestMapping("/demo/**")
class Demo{
@Request
public ModelAndView() {
ModelMap modelMap = new ModelMap();
modelMap.putAttribute("content", "Hello World, this is a sunny day...");
return new ModelAndView("demoView", modelMap);
}
}
demoView.jsp
...
<textarea name="input" cols="50" rows="10"><c:out value="content"/></textarea>
...
Upvotes: 2