Ich bin neu mit Feder, und ich folge diesem Schaffen Projekt Tutorial tutorial linkFrühling Daten vorbei
Aber mein jsp nicht wissen, die übergebenen Daten.
Hier ist meine hello.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
votre message est : ${message}
</body>
</html>
und meine helloController.java
package web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class helloController {
@RequestMapping("/hello")
public ModelAndView helloWorld(){
String message="Bonjour";
return new ModelAndView("hello","message",message);
}
}
und meine web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>projetSpring</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
und meine Dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
\t xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\t xmlns:context="http://www.springframework.org/schema/context"
\t xmlns:p="http://www.springframework.org/schema/p"
\t xmlns:jee="http://www.springframework.org/schema/jee"
\t xsi:schemaLocation="http://www.springframework.org/schema/beans
\t http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-4.0.xsd">
<context:component-scan base-package="web"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix"><value>/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean>
</beans>
Hier ist mein Projektverzeichnis und das hello.jsp Lauf Ergebnis:
Project directory + run result
dies versuchen: localhost: 8080/projetSpring/hello.htm –
Versuchen Sie, das Verzeichnis 'jsp/hello.jsp' von' WebContent' in den Ordner WEB-INF (WEB-INF \ jsp \ hello.jsp) zu verschieben, und ändern Sie die Eigenschaft 'name = prefix' in' dispatcher -servlet.xml' für '/ WEB-INF/jsp /' – Alberto
Vielen Dank, es funktioniert mit localhost: 8080/projetSpring/hello.htm, aber bitte geht es um URL-Muster in der web.xml oder es hat keine Beziehung ? – Mouad