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

  • SEARCH
  • Home
  • 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 9185175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:13:34+00:00 2026-06-17T19:13:34+00:00

I am new to spring and was working on the Hello world application in

  • 0

I am new to spring and was working on the Hello world application in MVC The URL mapping is searched as a corresponding view when i return the ModelAndView object from the controller..I have included all proper jars.This is the code..
/web-inf/sample-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.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">             (http://www.springframework.org/schema/context/spring-context-3.0.xsd%27%3E)
   <context:component-scan base-package="com.tcs.laks.sample.controller" />
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
         <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean> </beans> 

This is the 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">    (http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd%27%3E)
   <display-name>Spring MVC Application</display-name>

   <servlet>
      <servlet-name>sample</servlet-name>
      <servlet-class>
         org.springframework.web.servlet.DispatcherServlet
      </servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>

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

</web-app>

The HelloWorldController is..

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.portlet.ModelAndView;

@Controller
@RequestMapping("/welcome")
public class HelloWorldController {

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView helloWorld(){
    String message = "Hello";
    return new ModelAndView("hello", "message", message);
   }
}

The url was given as //localhost:8080/sample/welcome it gave 404 as it was trying to find welcome.jsp instead of hello.jsp

HTTP Status 404 – /sample/WEB-INF/jsp/welcome.jsp


type Status report

message /sample/WEB-INF/jsp/welcome.jsp

description The requested resource (/sample/WEB-INF/jsp/welcome.jsp) is not available.


  • 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-06-17T19:13:36+00:00Added an answer on June 17, 2026 at 7:13 pm

    Specify the contextConfigLocation init-param for the dispatcher servlet within your web.xml file. The current configuration is even being read/used by the dispatcher

       <servlet>
          <servlet-name>sample</servlet-name>
          <servlet-class>
             org.springframework.web.servlet.DispatcherServlet
          </servlet-class>
          <init-param>
           <param-name>contextConfigLocation</param-name>
             <param-value>WEB-INF/sample-servlet.xml</param-value>
           </init-param>
          <load-on-startup>1</load-on-startup>
       </servlet>
    
       <servlet-mapping>
          <servlet-name>sample</servlet-name>
          <url-pattern>/</url-pattern>
       </servlet-mapping>
    

    Also it looks like you have imported the portlet version of ModelAndView, make sure this is what you desire. If not import, org.springframework.web.servlet.ModelAndView

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

Sidebar

Related Questions

I'm really new to Spring and Spring MVC and I'm working on a kind
I am new to Spring MVC. But I had certain experience in working with
I am new to Spring MVC . I have a web application. I have
I am very new to Android application development. Just started Hello world android application
I am new to Spring Security. I have been working on creating a custom
I am new to working with Spring on regular basis so I had a
We are working on a new project with Grails 2.0.1 and Spring Security. The
New to Spring-MVC. I want to store two properties (uploadFolder=.., downloadFolder=..) in a .properties
I am new to spring MVC. i have below project structure. Below are classes:
The Hello World example from SLF4J is not working for me. I guess this

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.