Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一个 method 上同时有 GET、POST等 只能检测到 GET #138

Open
kevinwang0224 opened this issue Jan 18, 2025 · 3 comments
Open

一个 method 上同时有 GET、POST等 只能检测到 GET #138

kevinwang0224 opened this issue Jan 18, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@kevinwang0224
Copy link
Contributor

示例代码:

@RestController
@RequestMapping("api")
public class DemoController {


	@GetMapping(value = "user")
	@PostMapping(value = "user1")
	public String case1() {
		return "user";
	}
}

实际截图

Image

@houxinlin houxinlin added the enhancement New feature or request label Jan 18, 2025
@houxinlin
Copy link
Owner

houxinlin commented Jan 18, 2025

虽然但是,这样springboot会识别吗,写当然没问题

@kevinwang0224
Copy link
Contributor Author

虽然但是,这样springboot会识别吗,写当然没问题

对,Spring 只会识别第一个😂,我之前提过 pr 支持过的 rose 框架,是可以同时标记 Get Post ,是我搞错了。

正确写法应该是类似这样

@RequestMapping(value = "user", method = { RequestMethod.GET, RequestMethod.POST })
public String case1() {
	return "user";
}

这样的话,感觉 Spring 的确实没必要改。rose 的后面我提交个 pr 吧?

@houxinlin
Copy link
Owner

spring的没有必要了,spring倒是支持多path,

Image

关键现在github上的分支不维护了,提了pr不好合,等我把代码整理一遍就可以提了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants