Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

333
Views
SpringMVC : view not found 404 error

Here is the folder structure

enter image description here

here is the Controller part , which i am able to hit

import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping
public class ControllerClass
{
    static Logger log = Logger.getLogger(ControllerClass.class.getName());

    @RequestMapping(value = "/")
    public ModelAndView callRequest()
    {
        String message = "HELLO SPRING MVC";
        return new ModelAndView("index", "message", message);
    }
}

Here is my servlet part

<context:component-scan base-package="com.java.learn.controller" />
<mvc:annotation-driven />
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/" />
    <property name="suffix" value=".html" />
</bean>

and this is my web.xml

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

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

i tried to add the url pattern as * but then i am not able to hit the controller. also in the servlet part i removed web-inf/jsp as i move my index.html in webapps folder.

with this code i am able to hit the controller but when i return the view as "index" view didn't get rendered.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

isn't it?

       <servlet-mapping>
          <servlet-name>Learn</servlet-name>
          <url-pattern>/</url-pattern>
       </servlet-mapping>
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!