How to read a MapString return, String Java in javascript?

1

When making a request to a java control that returns a key map and value "String":

@ControllerSupport
public Map< String, String > teste() {
    Map< String, String > teste = new HashMap< String, String >();
    teste.put( "Teste", "Teste" );
    return teste;
}

When printing the assigned request to the variable that accesses the service.

console.log($scope.teste);

Returned an error in the javascript log.

Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object

How do I get this value returned from Map in the Javascrip?

    
asked by anonymous 02.02.2016 / 21:06

1 answer

2

To determine with certainty the problem would have to have the code that makes the call, but based on two answers from the OS with the same error message, I can assume that the problem can be corrected using one of the solutions below.

  • You can add isArray: false if you are using the query action, like this:

    'query': {method: 'GET', isArray: false}

  • Or you can try to use the action get instead of query .

  • 03.02.2016 / 01:03