我有以下控制器方法:
@RequestMapping(method = RequestMethod.GET, value = "/account/{loginId:.+}")
public @ResponseBody CloudWebServiceResponse getLogin(@PathVariable(value = "loginId") String loginId) throws CloudWebServiceInvocationException {
return internalService.getLogin(progressId);
}
当将 loginId 传递为“abc.com”时,它会给出 406 状态码,否则它工作得很好。
我有以下 WebConfig 文件:
@Configuration
@Import(HibernateConfig.class)
@EnableWebMvc
// @EnableAsync()
// @EnableAspectJAutoProxy
@ComponentScan(basePackages = "com.azim.web.service.*", basePackageClasses = { WebSecurityConfig.class }, excludeFilters = { @ComponentScan.Filter(Configuration.class) })
public class WebConfig extends WebMvcConfigurationSupport {
@Override
protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false).favorParameter(true).parameterName("mediaType").ignoreAcceptHeader(true).useJaf(false).defaultContentType(MediaType.APPLICATION_JSON)
.mediaType("xml", MediaType.APPLICATION_XML).mediaType("json", MediaType.APPLICATION_JSON).mediaType("html", MediaType.APPLICATION_JSON);
}
@Bean(name = "validator")
public Validator validator() {
return new LocalValidatorFactoryBean();
}
}
它只为 .com 发送 406 状态代码,而不为 .randomvalue 发送。我尝试在 stackoverdflow 上添加其他线程建议的 jackson-core-asl 和 jackson-databind-asl jar,但对我没有任何作用。请帮忙解决这个问题。