0
I know it says it wasn’t found, but I can’t find where I went wrong.
My controller:
@Controller
public class ProdutoController {
@Inject
private Result result;
@Path("/")
public ArrayList<Produto> inicio(){
ArrayList<Produto> listaProduto = null;
try {
listaProduto = new ProdutoDao().listaProduto();
} catch (Exception e) {
System.out.println("error: "+e.getMessage());
}
return listaProduto;
}
@Path("/teste")
public void teste(){
result.include("mens", "alguma coisa");
}
}
My jquery:
function clicar(){
$.ajax({
url: '<c:url value="/teste" />',
dataType: 'string',
success: function(retorno){
alert(retorno);
}
});
}
Can anyone tell me what I did wrong?
Have you ever used Vraptor or is it the first time?
– DiegoAugusto
I am learning vraptor, ie it is the first time, need to map the method of the controler differently to call with jquery?
– Bandoleiro
I don’t use jquery, but I put http verbs on each map. Ex:
@Get
 @Path("/colaborador)
 public void listarTodos() {...
– DiegoAugusto
Try putting a
@get
on top of your method and see if it works, see on the console if the request is also made.– DiegoAugusto
Even with the @Get annotation not working yet, the browser displayed the error: "http://localhost:8080/vraptorTest/test 404 not found" logo jquery Made the request.
– Bandoleiro
Try this:
url: '<c:url value="/produto/teste" />',
– DiegoAugusto
I even tried, but it didn’t work, I didn’t set up mapping for the class, only the methods.
– Bandoleiro
Then try to configure, because this way how the front will know which method to call?
– DiegoAugusto
I created a jsp for the test method, just to test the call and called the url by the browser and it worked, msm without mapping as "product/test"
– Bandoleiro