Pom*_*rio 3 spring exception-handling
经过一段时间研究和尝试不同的东西后,我仍然无法在我的jUnit集成测试中调用我的@ExceptionHandler.请帮帮我理解原因?
@RequestMapping(value = "/someURL", method = RequestMethod.POST)
public ModelAndView batchUpload(@RequestBody final String xml, @RequestParam boolean replaceAll)
throws IOException, URISyntaxException, SAXException, ParserConfigurationException, InvocationTargetException, IllegalAccessException, UnmarshallingFailureException
{
StreamSource source = new StreamSource(new StringReader(xml));
DomainClass xmlDomainClass;
try
{
xmlDomainClass = (DomainClass) castorMarshaller.unmarshal(source);
}
catch (UnmarshallingFailureException me)
{
// some logging. this gets executed
throw me;
}
Run Code Online (Sandbox Code Playgroud)
.
@ExceptionHandler(Throwable.class)
public ModelAndView handleUnmarshallingExceptions(Throwable th)
{
// never executes anything in here
return new ModelAndView( /*some parameters */ );
}
Run Code Online (Sandbox Code Playgroud)
小智 5
Spring:RESTful控制器和错误处理帮助了我,我的问题是缺少这个:
@Component
public class AnnotatedExceptionResolver extends AnnotationMethodHandlerExceptionResolver{
public AnnotatedExceptionResolver() {
setOrder(HIGHEST_PRECEDENCE);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2279 次 |
| 最近记录: |