There was an unexpected error (404 Not Found) JSP and Spring Boot

Vladislav Solopov

When I try to translate a project into Spring Boot, I get an error-I can not understand what I did wrong. The suffix and prefix added to the property-file, tried to change the location of jsp,debager shows that in the controller's method comes. What have I done wrong? I will be grateful for any help

Error:

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

Tue Jul 17 00:45:23 EEST 2018 There was an unexpected error (type=Not Found, status=404). /Authorization.jsp

My current structure of project: enter image description here 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.solopov.hillel</groupId>
 <artifactId>uquiz</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>war</packaging>

 <name>uquiz</name>
 <description>The project allows you to create and conduct surveys to anyone who wants</description>

 <parent>
  <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.3.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-security</artifactId>
  </dependency>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-test</artifactId>
   <scope>test</scope>
  </dependency>
  <dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-taglibs</artifactId>
  </dependency>
  <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
  </dependency>
  <dependency>
   <groupId>org.apache.tomcat.embed</groupId>
   <artifactId>tomcat-embed-jasper</artifactId>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
  </dependency>
 </dependencies>

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


</project>

Spring Boot application.properties:

logging.level.root = info

spring.mvc.view.preffix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

spring.datasource.url=jdbc:mysql://localhost:3306/quizzes?autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext

Sping Security configuration: (Just in case)

package com.solopov.hillel.uquiz.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import javax.sql.DataSource;

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Autowired
    DataSource dataSource;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(new BCryptPasswordEncoder())
            .usersByUsernameQuery("select login,password,true from user where login=?")
             .authoritiesByUsernameQuery("select login, role from user where login=?");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http    .authorizeRequests()
                .antMatchers("/auth", "/reg","/welcomepage").permitAll()
                .antMatchers("/admin/**").hasAuthority("admin")
                .anyRequest().authenticated().and()
                .formLogin()
                .loginPage("/auth").usernameParameter("login")
                .permitAll()
                .and()
                .logout().logoutSuccessUrl("/auth")
                .and().csrf().disable();
    }
}

Method of Controller:

@RequestMapping(method = GET, value = "/auth")
    public String authorization() {
        return "Authorization";
    }

Start class:

@SpringBootApplication
public class UquizApplication {

 public static void main(String[] args) {
  SpringApplication.run(UquizApplication.class, args);
 }
}
Amith Kumar

Please correct typo in your property file: spring.mvc.view.preffix to spring.mvc.view.prefix

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Spring boot: 404 error when calling JSP using controller

Spring Boot Whitelabel Error page (type=Not Found, status=404)

Issue With Spring: There was an unexpected error (type=Not Found, status=404)

Spring Boot JSP 404

Spring Boot Error 404 Not Found Hibernate

Spring boot Jsp file not found

Spring boot 2.1.0 release Getting 404 not found error

Spring Boot /actuator returns 404 not found

Demo Spring Boot application for REST apis for CRUD operation throws 404 not found error

Spring Boot + JMustache 404 not found error for .html page from /resources/templates folder

Spring boot with authentication - login page not found (404)

JavaConfig Spring Web Flow returns 404 not found (JSP)

Spring Boot JSP not found

Whitelabel Error Page There was an unexpected error (type=Not Found, status=404). /WEB-INF/views/home.jsp

Spring Boot version 1.5.9 app does not open view file, not found error 404

HTTP Status 404 – Not Found Spring Boot

404 Not Found Images Spring MVC JSP

error 404 not found - servlet from JSP

spring boot jsp & executable jar throws /error

404 - Not Found Error RequestDispatcher jsp forward

URI not found 404 spring boot

Spring boot web app gives 500 internal server error instead 404 not found

Spring Boot: Controller - 404 Not Found

Spring Boot Rest : Error 404 not found when sending simple get request via Postman?

Spring Boot jsp file not found Error 404 weird prefix

Spring Boot, Status 404, Error "Not Found"

Spring Boot Application 404 Not Found

Spring-Boot Endpoint/Controller Not Found 404

Cannot DELETE data: There was an unexpected error (type=Not Found, status=404)