Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:07:21+00:00 2026-05-26T08:07:21+00:00

I am new to spring web mvc framework,and I use struts 2 before. I

  • 0

I am new to spring web mvc framework,and I use struts 2 before.

I create a new dynamic web project using eclipse EE,and add all the jars to the /web-info/lib.

The whole hierarchy of the project is like this:

SpringMVCTest
    WEB-INF
        web.xml
        example-servlet.xml
        jsp
            hello.jsp
        lib
            xxxx.jars
            .....

This is the servlet definition:

<servlet>
    <servlet-name>example</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>example</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

This is the example-servlet.xml:

<context:component-scan base-package="com.kk.web.controllers" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

And the controller:

package com.kk.web.controllers;
@Controller("example")
@RequestMapping("/example")
public class ExampleController {
    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hello";
    }

    @RequestMapping("/hello_jsp")
    public ModelAndView hello_jsp(){
        ModelAndView mv=new ModelAndView("hello");
        mv.addObject("message", "welcome");
        return mv;
    }
}

It worked when I run:

http://localhost:8080/SpringMVCTest/example/hello

But when I run:
http://localhost:8080/SpringMVCTest/example/hello_jsp
I got the warn:

2011-10-17 10:36:15 org.springframework.web.servlet.DispatcherServlet noHandlerFound
Warn: No mapping found for HTTP request with URI [/SpringMVCTest/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'example'

It seems that the ExampleController works,it dispatch the request “/example/hello_jsp” to the right view “jsp/hello.jsp”.

But then the spring take the file dispatch “/jsp/hello.jsp” as another request,then it will not find the matched url mapping in the “example” controller.

Why?? IMO,a requst must come from the client to server,the controller receive only one request here “/exmaple/hello_jsp”,isn’t it?

And How to fix it?

BTW,I can set the url pattern to "/*.xxx",but I do not want the suffix in the url.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:07:21+00:00Added an answer on May 26, 2026 at 8:07 am

    Previous answer did not work…

    This posting looks similar: http://forum.springsource.org/showthread.php?55982-No-mapping-found-for-HTTP-request-with-MVC-requests

    Summary: change

    <servlet-mapping>
        <servlet-name>example</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    

    to

    <servlet-mapping>
        <servlet-name>example</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    

    and checking my latest Spring MVC app I use the latter pattern (no * on the end).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Almost every new Java-web-project is using a modern MVC-framework such as Struts or Spring
I am writing Web app in java using Spring Web MVC framework. Somehow validation
I'm building a MVC web application (using the Spring MVC framework), and I'm a
I'm new to Tomcat, Maven and Spring Web MVC (framework v3 to be precise).
I am new to spring MVC coming with experience using PHP MVC frameworks and
I'm working on a reporting web application using JasperReport and Spring MVC 3 to
I am developing my application using spring-web-mvc... Now at my Controller it returns like
I'm completely new to the Spring framework (and most web development in general), but
I have been trying out the new Spring MVC 3.0 Type Conversion Framework. I
We are using Spring MVC 3.0 in our web application. We are also using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.