Não consigo visualizar o formulário, no controller do form eu coloquei um print antes do retorno e até ali chegou. Detalhe é que a página da home abre normalmente quando chamo sua uri
Devo estar perdendo algum detalhe
Código do controller:
package br.com.casadocodigo.loja.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by Calebe L. S. Machado on 20/05/2016.
*/
@Controller
public class ProductsController {
@RequestMapping("/products/form")
public String form() {
System.out.print("Chegou aqui 1");
return "products/form";
}
}
form.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Livros de java, Android, Iphone, PHP, Ruby e muito mais - Casa do código</title>
</head>
<body>
<form action="/casadocodigo/products" method="post ">
<div>
<label>Título</label>
<input type="text" name="titulo">
</div>
<div>
<label>Descrição</label>
<textarea rows="10" cols="20" name="descricao"></textarea>
</div>
<div>
<label>Páginas</label>
<input type="text" name="paginas">
</div>
<button type="submit">Cadastrar</button>
</form>
</body>
</html>
AppWebConfiguration
package br.com.casadocodigo.loja.configuration;
import br.com.casadocodigo.loja.controllers.HomeController;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
/**
* Created by Calebe L. S. Machado on 20/05/2016.
*/
@EnableWebMvc
@ComponentScan(basePackageClasses = {HomeController.class})
public class AppWebConfiguration {
@Bean
public InternalResourceViewResolver internalResourceViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
}
ServletSpringConfiguration
package br.com.casadocodigo.loja.configuration;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
/**
* Created by Calebe L. S. Machado on 20/05/2016.
*/
public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[0];
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] {AppWebConfiguration.class};
}
@Override
protected String[] getServletMappings() {
return new String[] {"/"};
}
}