- <mvc:annotation-driven ignoreDefaultModelOnRedirect="true" conversion-service="" validator="" message-codes-resolver="">
- <mvc:argument-resolvers>
- <bean class="com.lay.user.util.CustomerArgumentResolver"/>
- </mvc:argument-resolvers>
- <mvc:message-converters>
- <bean class=""/>
- </mvc:message-converters>
- <mvc:return-value-handlers>
- <bean class=""/>
- </mvc:return-value-handlers>
- </mvc:annotation-driven>
- <mvc:argument-resolvers>:参数解析器,可通过实现HandlerMethodArgumentResolver接口实现,该实现不会覆盖原有spring mvc内置解析对参数的解析,要自定义的内置支持参数解析可以考虑注册RequestMappingHandlerAdapter,以下为参考:
- @Component
- public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
- @Autowired
- private UserService userService;
- @Override
- public boolean supportsParameter(MethodParameter parameter) {
- return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
- }
- @Override
- public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
- NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
- //获取用户ID
- Object object = request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY, RequestAttributes.SCOPE_REQUEST);
- if (object == null) {
- return null;
- }
- //获取用户信息
- return userService.queryObject((Long) object);
- }
- }
代码说明: supportsParameter方法主要判别参数是否为该解析器所支持的,支持:true ,不支持:false
如果返回true的话则调用resolveArgument方法。
相关推荐
2. 配置SpringMVC:在SpringMVC的配置文件中,启用数据绑定和验证支持,通常是在`<mvc:annotation-driven>`标签内添加`<mvc:argument-resolvers>`和`<mvc:message-converters>`子元素。 3. 定义验证规则:使用...
<br>Published by Prentice-Hall in 1988 <br><br>ISBN 0-13-110362-8 (paperback)<br>ISBN 0-13-110370-9 <br><br>Contents<br>Preface <br>Preface to the first edition <br>Introduction <br>Chapter 1: A ...
<argument>arg1</argument> <argument>arg2</argument> </arguments> </configuration> </execution> <!-- 可以添加更多执行配置,以启动多个进程 --> </executions> </plugin> </plugins> </build> ``` 2....
- `argue` -> `argument`: 争吵 - `commit` -> `commitment`: 奉献 2. **v+tion** 结尾: - `inspire` -> `inspiration`: 灵感 - `pollute` -> `pollution`: 污染 - `predict` -> `prediction`: 预言 - `...
dubbo.xsd 复制代码 <dubbo:service/> 服务配置,用于暴露一个服务,定义服务的元信息,一个服务可以用多个协议暴露,一个服务也可以注册到多个注册中心。...<dubbo:argument/> 用于指定方法参数配置。
It is handled by Jad rather than the command shell, so on<br>UNIX the last argument should be single-quoted:<br><br> jad -o -r -sjava -dsrc 'tree/**/*.class'<br><br><br>In a case you want to check ...
<dubbo:argument/> <dubbo:parameter/> 协议参考手册 dubbo:// rmi:// hessian:// http:// webservice:// thrift:// memcached:// redis:// 注册中心参考手册 Multicast注册中心 Zookeeper注册中心 Redis注册中心 ...
- `argue` -> `argument`: 争吵 - `mit` -> `mitment`: 奉献 - `develop` -> `development`: 开展 - `govern` -> `government`: 政府 2. 动词加后缀 `-tion/sion` 变为名词: - `describe` -> `description`: ...
* <stdarg.h> : Variable Argument Lists * <stddef.h> : Definitions of General Use * <stdio.h> : Input and Output * <stdlib.h> : Utility functions * <string.h> : String functions * <time.h> : Time...
First we have to make sure that we have one and only one instance of Script Manager object on your page:<br><body><br><form id="form1" runat="server"><br><asp:ScriptManager ID="ScriptManager1" runat=...
project->settings->C/C++->preprocessor->additional include directory-> C:\temp\systemc-2.0.1\src Add Systemc.lib: project->add to project->files-> C:\temp\systemc-2.0.1\msvc60\systemc\debug\systemc....
<argument>target/${project.artifactId}-${project.version}.jar</argument> </arguments> </configuration> </plugin> </plugins> </build> ``` 配置完成后,运行`mvn package`命令,Maven会生成一个可执行...
GPU显卡的Compute Capability需>=5.3,否则会提示error: (-217:Gpu API call) invalid device function in function 'make_policy' 编译本接口所用的工具及环境: Cmake-3.17.5 VS2019 opencv-4.2.0 opencv-contrib...
If the <directory> argument is not present, report the current directory. If the directory does not exist an appropriate error should be reported. This command should also change the PWD environment ...
- `<dubbo:argument/>`:指定方法参数配置。 ##### 配置优先级: - 方法级配置优先级最高,接口级次之,全局配置最低。 - 同级配置中,消费者优先级高于提供者。 #### 六、服务提供者配置示例 - **配置应用程序...
<关系运算符>→=|<>|<|<=|>|>= <表达式>→+<项><项后缀> <项>→<因子><因子后缀> <因子>→标识符|无符号整数|(<表达式>) <项后缀>→<加型运算符><项><项后缀>|ε <因子后缀>→<乘型运算符><因子><因子后缀>|ε <加...
在数学的领域中,符号和表达式是表达思想和解决问题的关键工具。对于国际交流和学习,了解这些符号和表达式的英文说法至关重要。本篇将详细阐述一些常见的数学符号及其对应的英文表述,帮助读者掌握数学语言的国际化...
pom.xml中为:<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <id>exec-cnpm-install</id> <phase>prepare-package</phase> <goals>...
<load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>UtilDateConverterInit</servlet-name> <url-pattern>/utilDateConverterInit</url-pattern> </servlet-mapping> ``` 通过...