Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is this. I think the problem might be something in my web.xml file. Can you help me?

This is my index.html under WebContent
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Store</title>
</head>
<body>
	<a href="/store/addProduct.html">Add a product</a>
</body>
</html>


This is my addProduct.html under WebContent/Web-INF/html:
HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
<title>Add a product</title>
</head>
<body>
<!-- 	<form action="#" th:action="@{/newProduct}" method="post"> -->
<!-- 		<button type="submit">Submit</button> -->
<!-- 	</form> -->
</body>
</html>


This is my web.xml under WebContent/WEB-INF
XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>CrunchifySpringMVCTutorial</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  
    <servlet>
        <servlet-name>store</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>store</servlet-name>
        <url-pattern>/addProduct.html</url-pattern>
<!--         <url-pattern>/index.jsp</url-pattern> -->
<!--         <url-pattern>/welcome.html</url-pattern> -->
<!--         <url-pattern>*.html</url-pattern> -->
    </servlet-mapping>
  
</web-app>


This is my store-servlet.xml under WebContent/WEB-INF
XML
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:mvc="http://www.springframework.org/schema/mvc" 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.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd">
 
	<context:component-scan base-package="com.ecommerce.store" />
 
	<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/html/" />
		<property name="suffix" value=".html" />
	</bean>
 
</beans>


And no matter what I try I keep getting the same error:
Java
sept. 12, 2017 3:11:50 PM org.springframework.web.servlet.PageNotFound noHandlerFound
AVERTISSEMENT: No mapping found for HTTP request with URI [/store/addProduct.html] in DispatcherServlet with name 'store'


Can you help me please? I'm desperating.

What I have tried:

I've tried changing my web.xml in many ways but I cant get it right.
Posted
Updated 18-Sep-17 18:12pm

1 solution

Error is much clear that your provided page to navigate is not founded try full path to your link or try
<a href=@"your page path/file.html">Link</a>
 
Share this answer
 
Comments
Francisco Duarte DEV 19-Sep-17 8:59am    
thank you, that was my problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900