Search code examples
springspring-mvcservletshttp-status-code-404servlet-mapping

No mapping found for HTTP request with URI [/AdminTemplate/] in DispatcherServlet with name 'springapp'


for the first this error seems really silly and easy to fix but the problem is everything seems oke and i have no idea what cause it.I tried to configure this web project with java configuration and also xml and i get the same 404 error code.

WARNING: No mapping found for HTTP request with URI [/AdminTemplate/] in DispatcherServlet with name 'springapp'

If anyone can help me here i would really appreciate it. Here is my code:

web.xml

<welcome-file-list>
    <welcome-file>index.htm</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>springapp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/springapp-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>springapp</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

springapp-servlet.xml

<mvc:annotation-driven />
<context:component-scan base-package="com.admin.controller" />


<mvc:resources mapping="/resources/**" location="resources/" />

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView"></property>
    <property name="prefix" value="/WEB-INF/views/"></property>
    <property name="suffix" value=".jsp"></property>
</bean>

a simple controller

@Controller
public class PageController {

@RequestMapping(value = "/", method = RequestMethod.GET)
public String homePage() {

    return "index";

      }
  }

and a simple jsp which is not important.

My project structure is like this:

enter image description here

But ofcourse if i set in the web.xml

<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list>

and move the index.jsp file from jsp folder to webapps it works. Anyone has an idea what can cause this?Thanks in advance.

UPDATE:

I tested other project which worked in the past and now i get the same 404 error.


Solution

  • I managed to solve the problem temporarily buy changing the whole XML configuration to Java based configuration, after that i become 100% sure the problem is not with the code.I leave a link here for the other problem maybe someone will face the same.

    Tomcat error? Or something else?