-
Aug 21st, 2012, 01:25 AM
#1
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;
}
}
-
Aug 21st, 2012, 02:11 AM
#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).
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
-
Forum Rules