• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

SimpleUrlHandlerMapping is not Working

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used org.springframework.web.servlet.handler.SimpleUrlHandlerMapping

In 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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


<!-- ************************************ SimpleUrlHandlerMapping **************************************** -->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"/>


<!-- ************************************ CONTROLLER MAPPINGS **************************************** -->
<bean name="LoadEmployeeDetails" class="com.app.controller.LoadEmployeeDetailsController">
<property name="employeeService" ref="employeeService"></property>
<property name="applicationContextTest" ref="applicationContextTest"></property>
</bean>


In jsp page

<%
response.sendRedirect("LoadEmployeeDetails");
%>


In Web.xml

<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>

This is not working.
First time I am using this. Could anyone help me please.






 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can include following tag in your urlMapping tag :
<property name="mappings">
<props>
<prop key="/load.html">LoadEmployeeDetails</prop>
</props>
</property>


And make id="LoadEmployeeDetails" instead of name="LoadEmployeeDetails"

And in your jsp make redirect path to 'load.html'

I hope it should work .
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

abhi jitnag wrote:
This is not working.



You need to tell us the details. what does not work. How you ran this application?. What you get when you run this application?. Any exception or error?
Regarding the topic, you are telling your server to redirect all *.html requests to spring dispatcher servlet and redirecting to LoadEmployeeDetails. First, this request would not be handled by spring, you need to redirect to some .html, then in dispatcher-servlet.xml you can use what gireesh has suggested..

If you have error/exceptions after trying these, please post them here, we will try our best to help you..
 
reply
    Bookmark Topic Watch Topic
  • New Topic