【问题标题】:Using AngularJs Template value in Spring Controller在 Spring Controller 中使用 AngularJs 模板值
【发布时间】:2017-05-18 18:32:38
【问题描述】:

我想在spring Controller中使用angularJs Template值。

如果是这样的

ng-model=x

我们用{{x}}显示数据

如何在 Spring Rest Controller 的方法中使用这个 x 值 作为参数?

【问题讨论】:

  • 您可以将x作为参数发送给控制器。
  • 怎么样?我在那里挣扎
  • 尝试使用@RequestParam@PathVariable@RequestBody 等进行一些研究...
  • 感谢提供线索
  • @TheKojuEffect 解决了它

标签: angularjs spring spring-boot jhipster


【解决方案1】:

我已经解决了这个问题。

答案如下:

如果在 AngularJs在 HTML 模板中)是 {{x}}

然后在 Spring RestController 中我们可以使用 @RequestParam

因此,

@RequestMapping(value = "/TheAddress",
    method = RequestMethod.POST,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public TheName(@RequestBody String anystring,
                     @RequestParam("x") String asThevaliableToUseInTheControler) {

//The code
}

【讨论】:

  • 加一个用于发布解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-19
  • 2016-01-04
  • 1970-01-01
  • 2013-04-14
  • 2016-11-23
  • 2014-11-04
  • 1970-01-01
相关资源
最近更新 更多