1

Hi I have an stupid beginner question how to get an String from Controller to the .jsp view?

in the controller I have something like:

 @RequestMapping(value = "/users/add", method = RequestMethod.GET)
 public String showAddUserForm(Model model) {
 model.addAttribute("times1List", times1);
...
 String myText = "data from external whatever...";
 model.addAttribute("Group",myText);
...
return "users/userform";

my .jsp looks like

         <div>
           #
           <c:out value="${Group}"  />                        
           #
           ${Group}           

         </div>

I can't see the string, only the "#" are visible, can't see what the problem is

do I need "ModelAndView"? It can't be so complicated to output just an variable

w3Charlie
  • 85
  • 1
  • 3
  • 17
  • Its not like you only need modelandview. From jsp through ajax you can call your controller. From the controller using `@ResponseBody` you can return the string and in jsp you will be able to receive it.Then you can show it in any div. – Mithun Debnath Mar 03 '17 at 13:19
  • servlet version? http://stackoverflow.com/a/20415529/3959856 – Jack Flamp Mar 03 '17 at 13:22
  • I have changed it to output with model,because it is less work :p but could you give me an small hello world example how to use modelandview with @ResponseBody without Model class – w3Charlie Mar 06 '17 at 12:39

0 Answers0