I am trying to run spring mvc helloworld example by tutorialspoint.but I am not geeting the modelmap data in jsp page .I had added all the required jars in web-inf/lib folder.I am also using <%@ page contentType="text/html; charset=UTF-8" isELIgnored="false" %>
.But still i am not getting data in jsp page. i also view so many answers for this question on stackoverflow and on http://ift.tt/1BHCRGv this is my project flow.Please help Thanks in advance
. And my HelloController is
package com.tutorialspoint;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ui.ModelMap;
@Controller
@RequestMapping("/hello")
public class HelloController{
@RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}
web.xml is ::
<web-app id="WebApp_ID" version="2.4"
xmlns="http://ift.tt/qzwahU"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/qzwahU
http://ift.tt/16hRdKA">
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
HelloWeb-servlet.xml is
<beans xmlns="http://ift.tt/GArMu6"
xmlns:context="http://ift.tt/GArMu7"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="
http://ift.tt/GArMu6
http://ift.tt/QEDs1e
http://ift.tt/GArMu7
http://ift.tt/QEDs1k">
<context:component-scan base-package="com.tutorialspoint" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
and this is my hello.jsp::
<%@ page contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<html>
<head>
<title>Hello World</title>
</head>
<body>
hiiiii <h2>${message}</h2>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire