Bonjour,

je suis débutant dans le développement Java Web. Je tente de développer une application de test très simple intégrant Spring MVC.

Voici la configuration :

Web.xml
--------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">
 
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
 
    <servlet>
        <servlet-name>argf</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>argf</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
 
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
 
</web-app>
le fichier argf-servlet.xml
-------------------------------------

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
       http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
 
 
    <context:component-scan base-package="com.servlet.controller"/>
 
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix">
        <value>/</value>
      </property>
      <property name="suffix">
        <value>.jsp</value>
      </property>
    </bean>
 
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>    
</beans>
Ensuite le controlleur
--------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
package com.servlet.controller;
 
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
 
@Controller
@RequestMapping("/helloSpringMVC.html")
public class HelloSpringMVC {
 @RequestMapping(method = RequestMethod.GET)
  public  String sayHelloWithSpringMVC(
    @RequestParam(value="name",required=false) String name, ModelMap model)
  {
    model.addAttribute("name",name);
    return "WEB-INF/jsp/hello";
  }
}
et pour finir la jsp hello.jsp, dans /WEB-INF/jsp/
-----------------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page isELIgnored ="false" %>
 
<!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>Spring mvc hello !!</title>
</head>
<body>
 
Votre nom est : ${name}
 
</body>
</html>
Lorsque je deploie l'applic sous l'url http://localhost:8080/argf/helloSpringMVC.html?name=mic avec le serveur tomcat j'ai l'erreur suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Etat HTTP 500 -
 
type Rapport d'exception
 
message
 
description Le serveur a rencontré une erreur interne () qui l'a empêché de satisfaire la requête.
 
exception
 
org.apache.jasper.JasperException: java.lang.NullPointerException
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:527)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:359)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
cause mère
 
java.lang.NullPointerException
	org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
	org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.29.
Je ne vois pas ce qui cloche, mnt je ne connais pas très le fonctionnement de tout ca donc... Si qq pouvait m'aider ca serait le bienvenu

Voila, je travaille avec Idea, sous ubuntu

Merci d'avance

Edit:

En fait y a un truc vraiment bizarre :

si je mets dans mon web.xml :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
   <servlet>
      <servlet-name>FirstForm</servlet-name>
      <servlet-class>com.servlet.Form</servlet-class>
    </servlet>
 
    <servlet>
      <servlet-name>FormAction</servlet-name>
      <servlet-class>com.servlet.FormAction</servlet-class>
    </servlet>
        <servlet-mapping>
      <servlet-name>FirstForm</servlet-name>
      <url-pattern>/form</url-pattern>
    </servlet-mapping>
 
    <servlet-mapping>
      <servlet-name>FormAction</servlet-name>
      <url-pattern>*.do</url-pattern>
    </servlet-mapping>
et dans Form.java
------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
public void doGet(HttpServletRequest request,
		          HttpServletResponse response)
			throws IOException, ServletException{
 
  request.getRequestDispatcher("forms.jsp").forward(request, response);
}
et n'importe quoi dans forms.jsp et bien j'obtiens la meme erreur que tantot.. alors que la je vois pas vraiment d'erreurs...