0

私は持っている :

<context:annotation-config/>
<mvc:annotation-driven/>

私の appContext と私の pom には jackson が含まれています:

<dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>${org.codehaus.jackson-version}</version>
        </dependency>
      <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>${org.codehaus.jackson-version}</version>
        </dependency>

コントローラー@ResponseBodyの戻り値の型は ですList<Long>が、get 要求で nonparseablemedia 406 エラーが発生します。何が欠けていますか?

@RequestMapping(value = "/myUrl/{customerId}/{productId}/", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody List<Long> myMethod(@PathVariable Long customerId, @PathVariable Double productId) {
        List<Long> result = fieldService.identifyField(customerId, productId);
        return result;
    }

ユニットテストによって呼び出されています(IDは適切な変数です):

MockHttpServletRequestBuilder mockHttpServletRequestBuilder
                = get("/myUrl/"+customerId+"/"+productId);

        MvcResult mvcResult = this.mockMvc.perform(mockHttpServletRequestBuilder)
                .andDo(print())
                .andExpect(status().isOk())
                .andReturn();

リクエストの出力は、メソッドが見つかったことを示していますが、406、おっと!

Handler:
  Type = com.mycompany.MyController
  Method = public java.util.List<java.lang.Long>   uk.co.axiomtechsolutions.ipf.webapp.web.MyController.MyMethod(java.lang.Long,java.lang.Double)

Resolved Exception:
  Type = org.springframework.web.HttpMediaTypeNotAcceptableException
4

1 に答える 1