problems with web service Jquery + Vraptor 4 "status of 404"

Asked

Viewed 102 times

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?

  • I am learning vraptor, ie it is the first time, need to map the method of the controler differently to call with jquery?

  • I don’t use jquery, but I put http verbs on each map. Ex: @Get&#xA; @Path("/colaborador)&#xA; public void listarTodos() {...

  • Try putting a @get on top of your method and see if it works, see on the console if the request is also made.

  • 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.

  • Try this: url: '<c:url value="/produto/teste" />',

  • I even tried, but it didn’t work, I didn’t set up mapping for the class, only the methods.

  • Then try to configure, because this way how the front will know which method to call?

  • 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"

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.