fix(fit-http): 修复 RequestParam 不指定 name 属性时报错的问题#413
Open
Cherished-l wants to merge 1 commit intoModelEngine-Group:mainfrom
Open
fix(fit-http): 修复 RequestParam 不指定 name 属性时报错的问题#413Cherished-l wants to merge 1 commit intoModelEngine-Group:mainfrom
Cherished-l wants to merge 1 commit intoModelEngine-Group:mainfrom
Conversation
- 在 AbstractRequestParamMapperResolver 中添加 resolveParamName() 方法 - 实现参数名 fallback 逻辑:name > value > 参数名 - 更新所有 RequestXxxMapperResolver 实现类 - 改进所有 Fetcher 的错误信息,提供清晰的解决步骤 - 添加单元测试验证不同参数配置的行为 Fixes: ModelEngine-Group#120 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
修复 Issue #120:当前 FIT 框架中,
@RequestParam注解必须显式指定value属性,否则框架启动时会抛出IllegalArgumentException: The query key cannot be blank.异常。解决方案
实现参数名 fallback 逻辑,优先级:name > value > 参数名
当不指定
name或value属性时,自动使用方法参数名作为 query key(项目已配置-parameters编译参数)。修改内容
核心逻辑修改
AbstractRequestParamMapperResolver.java: 添加resolveParamName()方法,实现 fallback 逻辑RequestParamMapperResolver.java: 更新createSourceFetcher()使用 fallbackRequestHeaderMapperResolver.java: 更新createSourceFetcher()使用 fallbackRequestCookieMapperResolver.java: 更新createSourceFetcher()使用 fallbackRequestFormMapperResolver.java: 更新createSourceFetcher()使用 fallbackPathVariableMapperResolver.java: 更新createSourceFetcher()使用 fallback错误信息改进
QueryFetcher.java: 改进错误信息HeaderFetcher.java: 改进错误信息CookieFetcher.java: 改进错误信息FormUrlEncodedEntityFetcher.java: 改进错误信息PathVariableFetcher.java: 改进错误信息测试
HttpParamTest.java: 添加测试方法RequestParamMapperResolverTest.java: 添加 3 个单元测试用例使用示例
修复后可以使用更简洁的写法:
兼容性
name/value的代码行为不变检查清单
mvn clean install)🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Fixes: #120