简体   繁体   English

Java使用Spring Restful URL

[英]Java using Spring restful URL

I am using Java with Spring framework. 我在Spring框架中使用Java。

I have a multiaction controller which is having lots of service methods, and I want to to create restful URLs like as following: 我有一个具有许多服务方法的多动作控制器,并且我想创建如下的静态URL:

http://server.com/url/events/multiActionMethod1 http://server.com/url/events/multiActionMethod1

http://server.com/url/events/multiActionMethod2 http://server.com/url/events/multiActionMethod2

http://server.com/url/events/multiActionMethod3 http://server.com/url/events/multiActionMethod3

http://server.com/url/events/multiActionMethod4 http://server.com/url/events/multiActionMethod4

http://server.com/url/events/multiActionMethod5 http://server.com/url/events/multiActionMethod5

How can I achieve above tasks? 如何完成上述任务?

I think maybe something isn't coming through clearly in your question. 我认为您的问题可能未明确解决。 It reads like all you're looking for is this: 它看起来像您正在寻找的是这样的:

@RequestMapping("/events/multiActionMethod1")
public ReturnType multiActionMethod1(SomeParameter param) {
  //request handling logic
}

is there more to the question you could elaborate on? 您还有更多要解决的问题吗?

edit: ugh no, none of that is in 2. You'd need 2.5 for annotations and 3 if you want support for using parts of the url as parameters. 编辑:嗯,不,这都不是2。注释需要2.5,注释,如果要支持使用部分url作为参数,则需要3。 The easiest thing to do if you really want it to work that way in an older version is slap a URL rewriter on the front and convert it to regular query string before it hits spring. 如果您真的希望它在旧版本中能以这种方式工作,最简单的方法是在前面打一个URL重写器,然后在弹簧问世之前将其转换为常规查询字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM