SpringBoot and Angularjs Routes

3

I'm trying to put a friendly url to get the '#' from the angle of the url, I followed the following tutorial: # / spring-boot-as-a-backend-for-angularjs /

and it worked fine on the static url. But if I do this

  .state('site3.evento', {//angular
              url: '/evento/:informacaoEventoId',
              templateUrl: 'tpl-site/evento.html',

//Java
@RequestMapping(/evento/{informacaoEventoId})
public String evento() {
    return "forward:index.html";
}

@Override//Spting
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**").addResourceLocations(
            "/resources/");
    registry.addResourceHandler("/**").addResourceLocations("/");

}

As the id is dynamic beyond the error, it can not display the page the error is this:

o.s.boot.context.web.ErrorPageFilter     : Cannot forward to error page for request [/evento/208] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

Controller

@Controller
public class RouteController implements Serializable{

private static final long serialVersionUID = 1L;

@RequestMapping({
    "/",
    "/contato",
    "/politica-de-privacidade",
    "/quem-somos",
    "/termo-de-uso",
    "/faq/teste"
})
public String index() {
    return "forward:index.html";
}

@RequestMapping("/evento/{informacaoEventoId}")
public String evento(@PathVariable String informacaoEventoId) {
    return "forward:index.html";
}

}

Spring

@Configuration
@EnableAutoConfiguration
@ComponentScan  
public class Application extends SpringBootServletInitializer {  

@Override
protected SpringApplicationBuilder configure(
        SpringApplicationBuilder application) {
    return application.sources(Application.class);
}

public static void main(String... args) {
    System.setProperty("spring.profiles.default",
            System.getProperty("spring.profiles.default", "dev"));
    @SuppressWarnings("unused")
    final ApplicationContext applicationContext = SpringApplication.run(
            Application.class, args);
    }
}
    
asked by anonymous 07.08.2015 / 18:25

1 answer

1

The error I'm seeing is the lack of setting the InfoIdId parameter in the evento method. It should be annotated with @PathVariable

The code should look like this:

@RequestMapping(/evento/{informacaoEventoId})
public String evento(@PathVariable String informacaoEventoId) {
    return "forward:index.html";
}
    
07.08.2015 / 18:50