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 9233681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:36:47+00:00 2026-06-18T06:36:47+00:00

I am developing a simple spring REST web service. From the research I did

  • 0

I am developing a simple spring REST web service. From the research I did there could be two types of 404 exceptions.
For example,

@Controller
@RequestMapping("/person")
@Transactional(readOnly=true)
public class PersonController {     
    @RequestMapping(value="/data", method={RequestMethod.GET,RequestMethod.POST})
    @ResponseStatus(value=HttpStatus.OK)
    public Person getPerson() {
        return service.getPerson();
    }
}

Type 1: http://localhost/myws/person/get will throw a 404 from web service.
Type 2: http://localhost/myws/idontexist will throw a 404 from web server container. In my case it is tomcat.

To handle, Type 1, I tried extending DefaultHandlerExceptionResolver and overriding handleNoSuchRequestHandlingMethod
To handle Type 2, I added the below snippet in my web.xml

<error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/pages/notfound.jsp</location>
    </error-page>
    <error-page> 
        <exception-type>java.lang.Throwable</exception-type> 
        <location>/WEB-INF/pages/notfound.jsp</location> 
    </error-page>

My servlet xml looks like,


    <context:component-scan base-package="com" />
    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="ignoreAcceptHeader" value="true" />
        <property name="order" value="1" />
        <property name="contentNegotiationManager">
            <bean class="org.springframework.web.accept.ContentNegotiationManager">
                <constructor-arg>         
                    <bean class="org.springframework.web.accept.ParameterContentNegotiationStrategy">
                        <constructor-arg>
                            <map>
                                <entry key="json" value="application/json"/>
                                <entry key="xml" value="application/xml"/>
                            </map>
                        </constructor-arg>
                    </bean>
                </constructor-arg>
            </bean>
        </property>
        <property name="defaultViews">
            <list>

                <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
                <bean class="org.springframework.web.servlet.view.xml.MarshallingView">
                    <constructor-arg>
                        <bean class="org.springframework.oxm.xstream.XStreamMarshaller">
                            <property name="autodetectAnnotations" value="true"/>
                        </bean>
                    </constructor-arg>
                </bean>
            </list>
        </property> 
    </bean>

    <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
              <property name="order" value="2" />
              <property name="prefix">
                  <value>/WEB-INF/pages/</value>
               </property>
              <property name="suffix">
                 <value>.jsp</value>
              </property>
        </bean>
    <!--To handle Internal Server Errors -->
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver">
        <property name="order" value="1"/>
    </bean>
    <bean class="org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver" >
        <property name="order" value="2"/>
    </bean>
    <!--RestExceptionHandler extends DefaultHandlerExceptionResolver -->
    <bean class="com.rest.exception.RestExceptionHandler">
        <property name="order" value="3"/>
    </bean>   
    <!-- data source and Daos...-->

When I hit the Type 2 URL, I am getting the below Exception.
WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/myws/WEB-INF/pages/notfound.jsp] in DispatcherServlet with name 'restservlet'

But my JSP is present in the mentioned location. What could be the problem?

  • 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-18T06:36:48+00:00Added an answer on June 18, 2026 at 6:36 am

    This is what I did. I created a controller to handle 404 instead of JSP as I couldn’t get the problem with JSPs. It works as expected.

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

Sidebar

Related Questions

I am developing a simple web service with Spring 3.1.3 and spring ws-2.1.1. My
I'm developing simple Windows Service sending and receiving data from remote web service. I
I am using spring 3.0.2 for developing a simple web based application like twitter.
I'm currently developing a REST web service using Web API . I have encountered
I've been developing a simple Spring MVC application as a reporting service. Locally, I've
I'm developing a simple webapp based on Spring framework. I have these two files
So, i am developing simple web application using Spring Framework. The application users can
I am developing a simple web application using Spring framework 3.1.3.RELEASE & MAVEN. My
I developing a web application with a lot of libraries like, Spring, Apache CXF,
I'm developing a simple shopping application for Android. The app requires two SQLite database

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.