Announcement Announcement Module
Collapse
No announcement yet.
ModelAndView AddObject View doesn't receive the object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ModelAndView AddObject View doesn't receive the object

    Hello, I'm starting to develop with Spring MVC, I'm trying to do an app that shows a message in a view, i have this controller

    Code:
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.portlet.ModelAndView;
    
    @Controller
    public class Controlador {
    	
    	@RequestMapping(value="/tabla")
    	public ModelAndView muestraTabla(){
    		ModelAndView vista=new ModelAndView("tabla");
    		vista.addObject("message", "This is the message");
    		return vista;
    	}
    	
    }
    And I have this JSP page "View": tabla.jsp

    Code:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Informacion Tabla</title>
    </head>
    <body>
    <c:out value="${message}"/>
    </body>
    </html>
    And in the view, it shows a blank page, to verify that it would be showing the view, y try this

    Code:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Informacion Tabla</title>
    </head>
    <body>
    <c:out value="'${message}'"/>
    </body>
    </html>
    And it shows a page with '', could someone help me???

    Thanks

  • #2
    Hello again, I found this Thread and try the solution that he found, and IT WORKS!!!!!!!!!!!!!!
    I do this

    Code:
    @RequestMapping(value="/tabla")
    	public String muestraTabla(ModelMap m){
    		m.addObject("message", "This is the message");
    		return "tabla";
    	}
    But eclipse says that it is a Deprecated method, could someone tells me a better solution???

    Thank's a lot!!!

    Comment

    Working...
    X