John VanSickle
John VanSickle

Reputation: 13

Custom function with additional argument using Struts 2 REST plugin

Is there anyway to have additional arguments in the URL of a Struts2 REST plugin controller?

For example, I have:

public class PersonController() implements ModelDriven<Object> {

    private Integer id;
    ...

    public String comment() { ... };
    // Getter and Setter for id
}

which is successfully reached with

[domain]/person/{id}/comment

However, what I would like to be able to is have a URL like

[domain]/person/{id}/comment/{commentId}

Upvotes: 1

Views: 255

Answers (1)

Roman C
Roman C

Reputation: 1

It would be not REST style to have such URLs. Instead, you can use two URLs to access different resources.

 [domain]/person/{id}

 [domain]/comment/{commentId}

On the other hand if you mix convention and rest style mapping you can use namedVariable or regex pattern matcher to achieve what you would like to have.

Upvotes: 0

Related Questions