I configured Spring 4 to work without xml.
I created a simple @RestController
, like this:
@RestController
public class JogadorRest {
@RequestMapping("/ola/{jogador}")
public Jogador message(@PathVariable String jogador) {
Jogador j = new Jogador();
j.setNome(jogador);
return j;
}
}
But when I test in Postman ( link ), I get HTML instead of json:
<html>
<head>
<title>Error</title>
</head>
<body>/RestTestJogador/WEB-INF/view/ola/Liorr.jsp</body>
</html>
Why does this happen?
Will it be the way I set up spring? My configuration looks like this:
@Configuration
@ComponentScan("br.com.testejogador.default")
@PropertySource(value = { "classpath:application.properties" })
public class AppConfig {
@Autowired
private Environment env;
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/view/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
}