Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring MVC cast主体对象_Java_Spring_Spring Mvc - Fatal编程技术网

Java Spring MVC cast主体对象

Java Spring MVC cast主体对象,java,spring,spring-mvc,Java,Spring,Spring Mvc,我目前在我的Spring MVC项目中做了很多工作: protected String onSubmit(UploadMessagesCommand command, Principal principal) throws Exception { MyCustomUserDetailsImpl user = (MyCustomUserDetailsImpl) principal; //etc } 有没有更好的方法来实现这一点,这样我就可以用用户参数替换主参数并避免强制转换?我灵

我目前在我的Spring MVC项目中做了很多工作:

protected String onSubmit(UploadMessagesCommand command, Principal principal) throws Exception {
    MyCustomUserDetailsImpl user = (MyCustomUserDetailsImpl) principal;
    //etc
}

有没有更好的方法来实现这一点,这样我就可以用用户参数替换主参数并避免强制转换?

我灵活地注意到,您可以直接使用用户(详细信息)

protected String onSubmit(UploadMessagesCommand command, User user) throws Exception {
   //etc
}

我灵活地注意到,您可以直接使用用户(详细信息)

protected String onSubmit(UploadMessagesCommand command, User user) throws Exception {
   //etc
}