1
我在我的Spring Web模型 - 視圖 - 控制器(MVC)框架中有這個類。春天的Web模型 - 視圖 - 控制器(MVC)架構的版本是3.2.8Spring MVC:管理異常
我有這個控制器
public class WelcomeController extends ViewController {
@Autowired
private UserService userService;
@Autowired
private SessionHelper sessionHelper;
public ModelAndView handleRequest(final HttpServletRequest request, HttpServletResponse response) throws Exception {
sessionHelper.invalidate(request, new String[] { SubmitController.CONFIRMATION_INFO,
SubmitController.CONFIRMATION_INFO2,
SubmitController.CONFIRMATION_INFO3,
"changePrdStatus" });
HttpSession session = request.getSession();
DetailedUser ecasUser = (DetailedUser)request.getUserPrincipal();
User usr = userService.getUserFromLDAP(ecasUser);
..
}
拋出這個異常
com.tdk.iop.domain.security.ApplicationException: more than 1 user with the same email
at com.tdk.iop.dao.impl.UserDaoImpl.findByEmail(UserDaoImpl.java:195)
at com.tdk.iop.services.impl.ServiceSupport.getEcasUser(ServiceSupport.java:46)
at com.tdk.iop.services.impl.UserServiceImpl.getUserFromEcas(UserServiceImpl.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy596.getUserFromEcas(Unknown Source)
at com.tdk.iop.controller.welcome.WelcomeController.handleRequest(WelcomeController.java:64)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
這在網絡上。 xml
<error-page>
<exception-type>com.tdk.iop.domain.security.ApplicationException</exception-type>
<location>/errors/error500.do</location>
</error-page>
但是應用程序沒有達到Error500Controller
我覺得你的問題是連接方法簽名。你配置* spring-mvc *來處理* ApplicationException *,但是你的方法拋出了一個更通用的* Exception *。也許你必須改進* spring-mvc *配置。 –
您必須在Spring配置xml中添加SimpleMappingExceptionHandler bean。點擊此鏈接https://www.mkyong.com/spring-mvc/spring-mvc-exception-handling-example/ – Hiren