Vraptor: route conflict

1

I'm developing a news system for a client, and I'm going through a difficulty, the moment I'm going to record the news in the bank, the following message appears:

  POST: [FixedMethodStrategy: / news / {latestListlist} plus [POST]], [FixedMethodStrategy: / news / persist persist]

java.lang.IllegalStateException: There are two rules that match the uri '/ news / persist' [POST]] with same priority. Consider using @Path priority attribute.

In my controller the persistence method looks like this:

NewsController.java

@Post("/noticias/persistir")
public void persistir(Noticia noticia){
     [...]
}

And my form for editing or inserting news is like this:

<form action="<c:url value='/noticias/persistir'/>" method="post"
            class="form-horizontal" role="form">

      <input type="hidden" class="form-control" placeholder=""
                name="noticia.tipo" value="Noticia"/> 
//corpo do formulário tudo correto

</form>

This form if insertion and editing already worked, but began to point out that error, what can be? And how do I correct it?

    
asked by anonymous 19.08.2015 / 18:26

1 answer

4

Alright? The mistake itself already gives you a good tip. The following two routes conflict:

/noticias/{listaUltimasNoticias} e noticias/persisti

The problem is that the first one receives a variable as a parameter, and because it is a variable, {listaUltimasNoticias} can be anything, including persisti which is the suffix of the second path. Some alternatives to solve are:

1) change any of the two routes, of course

2) Set priority in your path. For example:

@Post @Path(value='/noticias/persisti', priority=HIGHEST) public void seuMetodo() {...}

You can find a complete explanation, with an example in: link

    
19.08.2015 / 22:50