Manish Mahajan
Manish Mahajan

Reputation: 1170

Not able to read data send by controller on jsp

I am trying to send data on jsp from my controller and trying to read it with Spring EL but i am not able to do it.

Controller:

 @RequestMapping("/home")
    public String StudentHome(RedirectAttributes ra){
        String msg="mydata";
        ra.addFlashAttribute("msg", msg);
        return "home";
 }

jsp:

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
    ${msg}
</body>
</html>

Do i need to include anything else?

Upvotes: 2

Views: 145

Answers (2)

Bharath
Bharath

Reputation: 259

RedirectAttribute is only used when you redirect. Try using return "redirect:home"; -BCP

Upvotes: 1

Jordan.J.D
Jordan.J.D

Reputation: 8113

  1. Add the @Controller annotation above the @RequestMapping annotation

  2. Make a bean for your controller in controller-spring-beans.xml.

Sample

<bean name="yourController"

    class="your.package">

    <property name="successView" value="path/to/your.jsp" />

</bean>

Read about Spring here

Upvotes: 0

Related Questions