Announcement Announcement Module
No announcement yet.
Set port number Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set port number

    I want to do something very easy, but I've nothing found in the documentation.
    I want to set the port number for the URI I request. For instance in, but there is no possibility to do that.

    I don't want to use the way or something like that, because in my app the user has the possibility to add a custom URI and if he adds something like, I can't just add the port :8080 to the end. Sure, I could manipulate the string, but I'm looking for a clean solution.

    Someboy any idea?

    Thx in advance!

  • #2
    I think you could use path variables. For example:

    String URL = "http://{hostname}:{port}/{resource}/{id}"

    // These values can be retrieved from your application UI
    String hostname = "";
    String resource = "post"
    String id = "1";

    String result = restTemplate.getForObject(URL, String.class, hostname, resource, id);

    Best Regards!


    • #3
      thanks for your reply. But isn't it the way I wanted to avoid like I stated in my first post?
      My problem is, that the user could enter in some form an address like "". I have then to manipulate the string in order to set the port like you suggested. Do you understand my problem?

      Best regards