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.
更多推荐
发布评论