- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有以下方法:
@RequestMapping(value = "/path/to/{iconId}", params="size={iconSize}", method = RequestMethod.GET)
public void webletIconData(@PathVariable String iconId, @PathVariable String iconSize, HttpServletResponse response) throws IOException {
// Implementation here
}
我知道如何使用 @PathVariable 从 RequestMapping 传递变量“webletId”,但是如何从参数中引用变量“iconSize”?
非常感谢。
最佳答案
使用@RequestParam
:
@RequestMapping(value = "/path/to/{iconId}", method = RequestMethod.GET)
public void webletIconData(@PathVariable String iconId,
@RequestParam("size") String iconSize,
HttpServletResponse response) throws IOException { ... }
另请参阅:
关于java - Spring MVC 从 RequestMapping 引用 params 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5000876/
如何在Spring中忽略类级别@RequestMapping("/home")并直接调用方法级别@RequestMapping("/users")? @Controller @RequestMappi
让我们假设以下 Controller : @RestController public class MyController { @RequestMapping(method = GET, pat
我在使用 Spring Boot 时遇到了一些问题。 当我使用 @RequestMapping(value = "/home") 时,一切正常。但是当我使用 @RequestMapping(name
我正在尝试创建一个restful API(使用Spring Boot v2.0.0.Release),我希望有一个端点,但我希望有两种可能的用途: GET /time - outputs curren
我已经被这个错误困扰了几个小时。。我的pom.xml。应用程序未启动。所有的Spring框架依赖于相同的版本,但仍然得到相同的错误。。更新。MVN依赖的结果:树。看起来这里一切都很好。
我有以下三个 REST API 方法: @RequestMapping(value = "/{name1}", method = RequestMethod.GET) public Objec
我正在尝试为 spring @RequestMapping 注释创建值属性以像这样映射 url /educationDistrict/308/action/resetAddressesForYear/
如何定义 @RequestMapping 方法来显式允许匿名(未经授权)访问? 以下方法不起作用,总是收到 401 Unauthorized: @RequestMapping("/test") @Se
想象一下我有一个像这样的 Spring MVC Controller : @Controller @RequestMapping("/base-url") public class MyControl
如何处理除资源映射文件夹之外的所有 URL 请求? 在这个例子中,我处理了所有路径(这就是我想要的),但现在即使我设置也无法访问资源文件夹 里面dispatcher-servlet.xml @Req
我需要有一个/jsp/login 和/jsp/login?error 的映射 请注意,我无法使用/jsp/login?error=someval 然后检查参数是否具有该值或默认值。在这种情况下,不允许
让 Tomcat 启动并自动显示 index.jsp 文件的内容没有任何问题。然而,当我尝试使用 @Controller 和 @RequestMapping 时,我遇到了错误。这是我的 Control
我有以下文件夹结构: WEB-INF/ -- 页数/ ----home.jsp ----admin.jsp ----admin2.jsp ----admin3.jsp 我有以下 Controller
我正在使用 Spring Boot,并尝试显示 get 请求。我正在使用 2 个类:Greeting.java 和 GreetingController: package greeting;
我正在尝试使用 @RequestMapping与 consumes -元素。阅读API-document它适用于 Content-Type - 请求头。但是,使用 @RequestMapping(co
我已经为此打开了一个问题 here.但我也想问一下 stackoverflow 的人。 @Controller @RequestMapping("/xxx") public class MyContr
我想在我的 Spring Boot 应用程序中创建一个自定义注释,它总是向我的类级别 RequestMapping 路径 添加一个前缀。 我的 Controller : import com.sage
鉴于下面的@Controller,即使我向 webApp 发送 Get 请求, Controller 也会运行 homePage 方法。 @RestController @RequestMapping
我正在尝试设置 Controller ,但不幸的是无法查看输出...一切都正确渲染。当我访问 http://localhost:8080/CMT/content/edit 时,我得到一个 404 页面
在我的 Spring Controller 中,我创建了 3 个方法。方法 1 和方法 2 工作正常,但方法 3 给我带来问题 问题: org.springframework.web.servlet.
我是一名优秀的程序员,十分优秀!