简体   繁体   English

Jersey REST Web服务获取Web项目URL

[英]Jersey REST web service get web project URL

I have a simple REST web service with Jersey, and I have only one resource class, named categorizer . 我在Jersey上有一个简单的REST Web服务,并且只有一个资源类,名为categorizer

This resource will return a HTML form for a GET request. 此资源将返回GET请求的HTML表单。 When the user fills this HTML form, it will send a POST request to the same resource class, ie categorizer . 当用户填写此HTML表单时,它将向同一资源类(即categorizer)发送POST请求。 So my question turns to be how can I get the correct URL for action field in the HTML form, which is returned for the GET request. 因此,我的问题变成了如何获取HTML表单中用于action字段的正确URL,该URL是为GET请求返回的。 I wish this URL could be dynamic. 我希望这个网址可以是动态的。 In other words, it will work when it is deployed on different servers with different domain name (IP address). 换句话说,当将它部署在具有不同域名(IP地址)的不同服务器上时,它将起作用。

Thanks for your help ! 谢谢你的帮助 !

You can easily use JSP in conjunction with Jersey and dynamically create the HTML page you need. 您可以轻松地将JSP与Jersey结合使用,并动态创建所需的HTML页面。 An example for this can be found on this page . 可以在此页面上找到一个示例。

Hope this helps. 希望这可以帮助。

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

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