No mapping found for HTTP request with URI [/ Milicia] in DispatcherServlet with name 'dispatcher'

2

You can not find the uris that I type, it always gives the same error, I have already re-created it and still the error persists.

Follow the relevant classes and files.

relevant part of pom.xml

    <build>
    <finalName>Milicia</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>
<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
</parent>

<dependencies>

    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>jstl-impl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-servlet-api</artifactId>
        <version>7.0.30</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6.2</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-annotations -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.5.6-Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.0-api -->
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/jstl/jstl -->
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
</dependencies>

Class that configures scan packages

package br.com.finger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "br.com.finger.controller.*", "br.com.finger.utils.*" })
public class AppWebApplication{

    @Bean
    public ViewResolver viewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        return viewResolver;
    }

}

Class that configures the servlet

package br.com.finger.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer{

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[] {};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[] {
                AppWebApplication.class, 
                JPAConfiguration.class
                };
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/*"};
    }
}

When I upload tomcat there is no error, when I call any uri the following warn

16:31:47.562 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'dispatcher' processing GET request for [/Milicia]
16:31:47.568 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /
16:31:47.569 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Did not find handler method for [/]
16:31:47.571 [http-nio-8080-exec-4] WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/Milicia] in DispatcherServlet with name 'dispatcher'
16:31:47.571 [http-nio-8080-exec-4] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request

CLASS login controller ... that brings this mentioned uri

@Controller
@Transactional
public class LoginController {

    private LoginHelper helper;

    @Autowired
    public LoginController(LoginHelper loginHelper) {
        this.helper = loginHelper;
    }

    //MAPEIA A ENTRADA PRINCIPAL DO SITE, TODOS AS PAGINAS
    //QUE NÃO TIVER SESSÃO LOGADA, VAI REDIRECIONAR PARA AQUI.
    @RequestMapping("/login")
    public String pageLogin(ErroLogin erro, HttpSession session){

        // se já tiver uma session rolando, vai para o dashboard
        if(session.getAttribute("user") != null){
            return "dashboard";
        }

        if(erro.isPassword()){
            //pinta o campo de senha de vermelho
        }

        if(erro.isUsername()){
            //pinta o campo de usuario de vermelho
        }

        //depois de tudo SEMPRE retorna a pagina de login
        return "/WEB-INF/VIEWS/pages-login.jsp";
    }
    
asked by anonymous 19.10.2016 / 20:33

1 answer

1

Apparently the mapping is not working as the Warning is giving:

16: 31: 47.571 WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI in dispatcherServlet with name 'dispatcher'     

19.10.2016 / 20:37