tags:

views:

3159

answers:

3

Hello All,

I'm getting this error.

my web.xml has this

<servlet>
  <servlet-name>springweb</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/web-application-config.xml</param-value>
   </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
  <servlet-name>springweb</servlet-name>
  <url-pattern>/app/*</url-pattern>
</servlet-mapping>

I have this in my web-application-config.xml

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
       <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
</bean>

<bean name="/Scheduling.htm" class="com.web.SchedulingController"/>

my com.web.SchedulingController looks like this

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.web; 

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;


public class SchedulingController implements Controller{

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

    ModelAndView modelAndView = new ModelAndView("/jsp/Scheduling_main.jsp");
    modelAndView.addObject("message","Hello World MVC!!");
    return modelAndView;
}
}

When I hit this controller with the URL http://localhost:8080/project1/app/Scheduling.htm The Scheduling_main.jsp gets displayed but the images are not displayed properly. Also the js and css file are not getting rendered.

I'm accessing the images like this

<img src="jquerylib/images/save_32x32.png" title="Save Appointment">

If I change the URL mapping in the servlet definition to *.htm, the images get displayed fine. Can you point out where I'm missing out.

Here is complete error message

WARN  [PageNotFound] No mapping found for HTTP request with URI [/mavenproject1/app/jquerylib/images/save_32x32.png] in DispatcherServlet with name 'springweb'

Thanks a lot. Ravi

+1  A: 

I'm think it happens because you try get your image though servlet (mapped as /app/*) You need get static content without handle it with your servlet, for example set image source to

<img src="../jquerylib/images/save_32x32.png" title="Save Appointment">

then real URI of your image will be /mavenproject1/jquerylib/images/save_32x32.png, and it will returned by your tomcat itself as is, without any processing.

Alexey Sviridov
Thanks a lot, it worked. Just got to learn more about URL mappings.
Ravi
A: 

You can look at this url, want to help you

http://www.javabloger.com/article/no-mapping-found-for-http-request-with-uri.html

JavaBloger
A: 

I just add three rules before spring default rule (/**) to tuckey's urlrewritefilter (urlrewrite.xml) to solve the problem

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN" "http://tuckey.org/res/dtds/urlrewrite3.0.dtd"&gt;
    <urlrewrite default-match-type="wildcard">
        <rule>
            <from>/</from>
            <to>/app/welcome</to>
        </rule>
        <rule>
            <from>/scripts/**</from>
            <to>/scripts/$1</to>
        </rule>
        <rule>
            <from>/styles/**</from>
            <to>/styles/$1</to>
        </rule>
        <rule>
            <from>/images/**</from>
            <to>/images/$1</to>
        </rule>
        <rule>
            <from>/**</from>
            <to>/app/$1</to>
        </rule>
        <outbound-rule>
            <from>/app/**</from>
            <to>/$1</to>
        </outbound-rule>    
    </urlrewrite>

http://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something/3614036#3614036

Pablo Cantero