1

I am getting this error:

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon May 21 12:25:52 EDT 2018 There was an unexpected error (type=Not Found, status=404). No message available

ControllerClass

package com.sampletwo.location.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LocationController {

@RequestMapping("/showCreate")
public String showCreate() {
return "createLocation";
}

}

JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Create Location</title>
</head>
<body>
<form action="" method="">
Id: <input type="text" name="id"> 
Code: <input type="text" name="code"> 
Name: <input type="text" name="name"> 
Type: Urban <input type="radio" name="type">
      Rural <input type="radio" name="type">

 <input type="submit" value="save">

</form>
</body>
</html>

application.properties

 spring.datasource.url=jdbc:mysql://localhost:3306/locationdb
    spring.datasource.username=root
    spring.datasource.password=kanth123

    spring.jpa.show-sql=true

    spring.mvc.view.prefix=/WEB-INF/views/
    spring.mvc.view.suffix=.jsp
    server.port=8080

    server.servlet.context-path=/locationwebproject

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.sampletwo.location</groupId>
<artifactId>locationwebproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>locationwebproject</name>
<description>Location Module</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

Please help me out.

Mikhail Kholodkov
  • 23,642
  • 17
  • 61
  • 78
coder2149
  • 39
  • 7
  • This means, an error has occurred and since you didn't explicitly defined an error page (`src/main/resources/static/error/errorCode.html`), this message is shown by default. – lealceldeiro May 21 '18 at 17:33
  • How can I resolve it? – coder2149 May 21 '18 at 17:34
  • If you are wondering why you are getting a 404 error, then however you are trying to reach that page is not calling the correct endpoint. I see you have a form? Are you trying to submit that form to the /showCreate endpoint? From your html is looks like there is no action or method specified, i.e. you have "
    " . Try looking at this stack overflow answer: https://stackoverflow.com/questions/31134333/this-application-has-no-explicit-mapping-for-error or this spring tutorial: https://spring.io/guides/gs/uploading-files/
    – bryant May 21 '18 at 17:36
  • which url do you call when you get the error? You can either provide a custom error page, or better call the correct url or provide a mapping for the url you want to call. – P.J.Meisch May 21 '18 at 17:36
  • http://localhost:8080/locationwebproject/showCreate – coder2149 May 21 '18 at 17:37
  • It is saying localhost page not found....because I have given context path as /locationwebproject – coder2149 May 21 '18 at 17:41
  • Possible duplicate of [Spring Boot Remove Whitelabel Error Page](https://stackoverflow.com/questions/25356781/spring-boot-remove-whitelabel-error-page) – Alien May 22 '18 at 05:46

0 Answers0