Spring 4 @RequestMapping处理带有特殊字符的REST URL(Spring 4 @RequestMapping handling REST URL with special ch

编程入门 行业动态 更新时间:2024-10-08 10:54:21
Spring 4 @RequestMapping处理带有特殊字符的REST URL(Spring 4 @RequestMapping handling REST URL with special characters)

Spring 4如何处理具有特殊字符的REST URL,例如#?

例如: http:// localhost:8080 /#/ members / browse?id = 1234

以下代码似乎无效。

因为Spring总是丢弃(包括)#之后的所有内容,只返回http:// localhost:8080的响应

谁能给我们一些帮助?

@RequestMapping(value = "/#/members/browse", method = RequestMethod.GET, produces = "application/json") public String findMembers(@RequestParam(value="id", required=false) { // some code }

How does Spring 4 handle the REST URL with special character, such as #?

For example : http://localhost:8080/#/members/browse?id=1234

The following code seems not working.

Because Spring always discards everything after (including) #, and just returns the response of http://localhost:8080

Could anyone give us some help?

@RequestMapping(value = "/#/members/browse", method = RequestMethod.GET, produces = "application/json") public String findMembers(@RequestParam(value="id", required=false) { // some code }

最满意答案

这是预期的行为。 它是一个片段标识符 ,并不意味着用于在服务器端路由请求。

在浏览器中,在同一页面中单击另一个锚链接(如#/members/browse?id=5678在页面中查找锚点,并且不会向服务器发送请求。

我想你可能正在使用一个javascript框架,如Ember或Angular,它们提供路由组件来在客户端路由这些事件并呈现视图。 请参阅Ember的路由器文档 。

This is the expected behavior. It's a fragment identifier and it's not meant to be used for routing requests on the server side.

In your browser, clicking on another anchor link like #/members/browse?id=5678 in the same page looks for an anchor within the page and does not send a request to the server.

I think you're probably using a javascript framework such as Ember or Angular, which provide routing components to route those events on the client side and render views. See the router documentation for Ember.

更多推荐

本文发布于:2023-04-29 07:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335575.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:特殊字符   REST   Spring   RequestMapping   special

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!