I can not view the jsp page of a Spring MVC project

0

I can not see the form.jsp page

I'm putting the following URL link

With this URL he only sees the hello-world.jsp page

I even put the following address link but it generates error, where am I going to be wrong.

here is my complete project;

link

part1;

public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer{

    @Override
    protected Class<?>[] getRootConfigClasses() {
        // TODO Auto-generated method stub
        return null;
    }


    // esse pedaço do código informa qual pagina ira ser mapeada
    @Override
    protected Class<?>[] getServletConfigClasses() {

        return new Class[]{AppWebConfiguration.class};
    }


    // esse código mapea o projeto
    @Override
    protected String[] getServletMappings() {
        // TODO Auto-generated method stub
        return new String[] {"/"};
    }

part2;

@EnableWebMvc
@ComponentScan(basePackageClasses={HomeController.class})
public class AppWebConfiguration {


    //esse pedaço do código informa aonde está a pagina dentro pacote especifico

    @Bean
    public InternalResourceViewResolver 
        internalResourceViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }

part3;

@Controller
public class HomeController {

    @RequestMapping("/")
    public String index(){

        System.out.println("carregando produto");
        return "hello-world";// essa é a pagina que está sendo visualizada
    }
    
asked by anonymous 13.10.2015 / 20:30

1 answer

1

Good afternoon, big take a look at your spring.xml file configuration and if you configured the welcome-list-file in web.xml, but if the configuration was done by annotated classes or beans look if in the configuration class of spring mvc you have configured the suffix and the prefix that it will inform the server to interpret and if you have configured the welcome file to what you want.

Okay, I understand now, in case you need to add the page you want to load in the views folder, in your controller when you put request mapping ("/") it is saying that every request made to the url http://localhost:8080/Loja/ will be handled by that class and in the method as the return is a string, this return represents the name of the view that after joining with the .jsp prefix that was set in the AppWebConfiguration class will be hello-world.jsp, ie, it will load on the screen view returned by the method, if you want to replace this view with another one just implement a new method with another request mapping or just change the return to the name of the page you want to load on the screen if you have an index.jsp page that you want to load it should be inside the views folder and in the return method you should enter the return as index.

    
13.10.2015 / 20:43