Results 1 to 2 of 2

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

  1. #1
    Join Date
    Aug 2012
    Posts
    1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •