I am new to spring MVC and maven also. I created a maven web project in eclipse. Add dependencies for spring and run the project, but i am not getting the desired result. Here is my project structure
When i run the project then i get the result Hello World which is my index.jsp
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
But when i change to url http://localhost:8080/Spring_Maven/jsp/hello i get HTTP Status 500 error. And when i change to url http://localhost:8080/Spring_Maven/jsp/hello.jsp then i get the output ${message}
Here is my hello.jsp page
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello</title>
</head>
<body>
<h1>${message}</h1>
</body>
</html>
Here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring_Maven</display-name>
<servlet>
<servlet-name>springMaven-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMaven-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springMaven-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
here is my springMaven-dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:component-scan base-package="pk.training.basitMahmood.springMaven.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
Here are the list of dependencies that i added through maven
What i am doing wrong?
Finally i made it work :). But i want to share so people with new to maven and eclipse could save their time.
First i installed the m2e eclipse WTP plugin and then create the maven project as i described in my question. The thing that you need to do is to add the compiler plugin and JDK version in your pom.xml else each time you do right click on project --> Maven --> Update project you get an error in the marker tab about JRE and java EE configuration problem. You also ned to change in project facets by doing right click on project --> properties --> Project facets --> Change java version. Here is the snippet of the pom.xml.
<build>
<finalName>SpringMavenHelloWorld</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Then in the web.xml i updated the servelt schema, and i found that i need to define my servet-dispatcer.xml file in both dispatcher-servlet and in the servlet context. Here is my web.xml
<?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_3_0.xsd"
version="3.0">
<display-name>Spring_Maven</display-name>
<servlet>
<servlet-name>springMaven-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springMaven-dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMaven-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springMaven-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Here is the structure of my project. I changed it a bit. Made a spring folder in WEB-INF and move the dispatcher servlet in it.
Although there is no lib folder in WEB-INF but everything is working fine. The thing that took my time so much is to define both servletcontext param and servelet init-param. If i only define servlet init param like
<servlet>
<servlet-name>springMaven-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springMaven-dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMaven-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springMaven-dispatcher-servlet.xml</param-value>
</context-param>
-->
then i got the error that
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from ServletContext resource
[/WEB-INF/applicationContext.xml]; nested exception is
java.io.FileNotFoundException: Could not open ServletContext
resource [/WEB-INF/applicationContext.xml]
and if i define only the context param like
<servlet>
<servlet-name>springMaven-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springMaven-dispatcher-servlet.xml</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMaven-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/springMaven-dispatcher-servlet.xml</param-value>
</context-param>
then i got the error that
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from ServletContext resource
[/WEB-INF/springMaven-dispatcher-servlet.xml]; nested exception is
java.io.FileNotFoundException: Could not open ServletContext resource
[/WEB-INF/springMaven-dispatcher-servlet.xml]
But defining both solve the issue. Now when i do right click on my project --> run on server then i get the page Hello World with url http://localhost:8080/SpringMavenHelloWorld/ and when i change it to http://localhost:8080/SpringMavenHelloWorld/hello then i get my desired output that is
Hope this will help others too. Thank you :)
Related
I need a REST Service to handle File uploads. I added the RESTEasy Multipart Provider dependency:
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.1.4.Final</version>
</dependency>
This somehow caused my other REST Services to stop working properly, and they now return errors:
<html>
<head>
<title>Error</title>
</head>
<body>Not Found</body>
</html>
or
<html>
<head>
<title>Error</title>
</head>
<body>HTTP method POST is not supported by this URL</body>
</html>
I read that this happens because the implementation of doGet() and doPost() are missing. I don't understand how simply adding this dependency affects my other webservices. Does it add a new Servlet ?
This is my Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<display-name>my_project</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.allowGenericHttpRequests</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowSubdomains</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, DELETE, OPTIONS, PUT</param-value>
</init-param>
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.exposedHeaders</param-name>
<param-value>Authorization, next-jwt-token</param-value>
</init-param>
<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.maxAge</param-name>
<param-value>3600</param-value>
</init-param>
</filter>
<filter-mapping>
<!-- CORS Filter mapping -->
<filter-name>CORS</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
</web-app>
The version of the dependency was not the one my wildfly was using. I solved my problem by changing the version to the correct one (3.0.24.Final, which ships with WildFly 11 Final), and I changed the scope to provided:
<!-- Resteasy-multipart-provider -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.0.24.Final</version>
<scope>provided</scope>
</dependency>
I have two context xml resides in WEB-INF folder; applicationContext.xml and app-servlet.xml. I declare this in app-servlet.xml
<context:component-scan base-package="com.training.hibernate.controller"/>
and this in applicationContext.xml
<context:component-scan base-package="com.training.hibernate.services"/>
<context:component-scan base-package="com.training.hibernate.dao"/>
I got this error
BeanCreationException: Error creating bean with name 'personController': Injection of autowired dependencies failed;
If I move the component scanning of services and dao in app-servlet.xml, I got no error. I assume the app-servlet.xml is not inheriting the applicationContext.xml
This is my web.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Spring Web Application</display-name>
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Here is some direction I can help you with to clarify different contexts. There are two main contexts usually in a Spring based web app :
Application Context : The context which contains the beans like services,dao etc.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-config/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
And then there is dispatcher servlet's context. This contains web specific beans . This context has access to beans defined via ContextLoaderListener above.
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-config/app-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Please verify, you have got this right.
I'm developing a Java EE application using web services to communicate with distant server.
To avoid Cross-origin resource sharing(CORS) problems I use a bridge Servlet to redirect and filter the requests.
However, when some distant pages are loaded the CSS and Javascript files located at this distant server will get their absolute path transformed and their root folder becomes the root of the local Web Application.
This is a chunk of HTML code of a distant web page called by the web application:
<!DOCTYPE HTML>
<html dir="ltr" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en">
<script type="text/javascript" src="/analytics/res/b_mozilla/browserdom.js">
</script>
src="/analytics/res/b_mozilla/browserdom.js" is located at http://remotehost:9704
but when it's loaded the path becomes http://localhost:8084/myWebApp/analytics/res/b_mozilla/browserdom.js which is a wrong path leading to this error The requested resource is not available.
What should I do to fix this error?
Update: web.xml content
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<servlet-name>ObieeBridge</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>ObieeBridge</servlet-name>
<servlet-class>ObieeBridge</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>ObieeBridge</servlet-name>
<url-pattern>/ObieeBridge</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
I am developing a web application using Spring and Tomcat 7.0. When I test the page in a browser it does not apply the CSS because it is unable to load the external stylesheet.
Here are my various files
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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MyProject</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ResourceServlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ResourceServlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
dispatcher-servlet.xml
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean id="userService" class="com.abdus.service.UserServiceImpl" />
<context:component-scan base-package="com.abdus.web" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>
and this is the head from jsp page
welcomePage.jsp
<meta charset="utf-8"/>
<title>Welcome</title>
<link rel="stylesheet" href="/resources/dream.css" type="text/css" />
You're saying the css url is not accessible (as opposed to it not being applied to your jsp) right? What's the response when you browse to /resources/dream.css?
I have had issues before with tomcat not serving static content with a /* servlet mapping. The way I solved it was to explicitly map each content type in web.xml, including .css files, like so:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
(where the "default" servlet is predefined by tomcat in conf/web.xml as org.apache.catalina.servlets.DefaultServlet)
It was actually a path issue. This was my directory structure
MyProject/WEB-INF/resources/dream.css
and in jsp link i had given it as href="/resources/dream.css" and i even tried href="MyProject/resources/dream.css".
But the wasy i resolved it is I made directory structure as
MyProject/resources/dream.css and
href="MyProject/resources/dream.css"
You could use jstl tags:
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link href="<c:url value="/resources/style.css"/>" rel="stylesheet" type="text/css" />
Or you could use full resources path:
<base href="http://localhost:8080/myapp/" />
<link href="resources/style.css" rel="stylesheet" type="text/css" />
My set up is as follows:
Tomcat 7
Spring MVC 3.0.6
Eclipse Indigo
File structur looks like this
src
- main
- java
- resources
- mdp-servlet.xml
- mdp-service.xml
- webapp
- WEB-INF
- web.xml
- test
mdp-servlet.xml
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="ch.hszt.mdp.web" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
mdp-service.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="userService" class="ch.hszt.mdp.service.UserServiceImpl" />
</beans>
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_2_5.xsd"
id="WebApp_ID" version="2.5">
<!-- Needed to see file mdp-service.xml -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:mdp-service.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<display-name>testing</display-name>
<servlet>
<servlet-name>mdp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mdp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<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>
</web-app>
Sourcefolder:
src/main/java
src/main/resources
src/test/java
This is the error message I get when I try to start the project with Tomcat within eclipse
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/mdp-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/mdp-servlet.xml]
Has anyone an idea to fix this?
Thx a lot!
found the solution
<servlet>
<servlet-name>mdp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:mdp-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mdp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>