Announcement Announcement Module
Collapse
No announcement yet.
set a value into a model, and fail to display the value in JSP via EL Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • set a value into a model, and fail to display the value in JSP via EL

    I have problem when i read a tutorial about spring mvc.The project have jsp page like:

    <html>
    <head>

    <title>Spring 3.0 MVC Series: Hello World - ViralPatel.net</title>
    </head>
    <body>
    hello!
    ${inf}
    </body>
    </html>

    And when i set a value for the inf in the controller,but,the "${inf}" fails to retirve the value.

    what should i do now?

    thx

    add:
    the controller's code:

    package net.viralpatel.spring3.controller;

    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMap ping;
    import org.springframework.web.portlet.ModelAndView;


    @Controller
    public class HelloWorldController {

    @RequestMapping("hello")
    public ModelAndView helloWorld() {

    String message = "Hello World, Spring 3.0!";
    System.out.println(message);
    ModelAndView modelandview=new ModelAndView("hello");
    modelandview.addObject("inf", message);
    //return new ModelAndView("hello", "message", message);
    return modelandview;
    }

    }

  • #2
    Please use [ code][/code ] tags when posting code that way it remains readable.

    Assuming you want to use the normal (web not portlet) stuff I suggest changing to the correct ModelAndView (web.servlet and not web.portlet).

    Comment

    Working...
    X