Custom function with additional argument using Struts 2 REST plugin(使用 Struts 2 REST 插件的带有附加参数的自定义函数)
问题描述
在 Struts2 REST 插件控制器的 URL 中是否有额外的参数?
Is there anyway to have additional arguments in the URL of a Struts2 REST plugin controller?
例如,我有:
public class PersonController() implements ModelDriven<Object> {
private Integer id;
...
public String comment() { ... };
// Getter and Setter for id
}
成功到达的地方
[domain]/person/{id}/comment
但是,我希望有一个类似的网址
However, what I would like to be able to is have a URL like
[domain]/person/{id}/comment/{commentId}
推荐答案
不是 REST 样式有这样的 URL.相反,您可以使用两个 URL 来访问不同的资源.
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}
另一方面,如果您混合使用约定和其他样式映射,您可以使用 namedVariable
或 regex
模式匹配器来实现您想要的.
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.
这篇关于使用 Struts 2 REST 插件的带有附加参数的自定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Struts 2 REST 插件的带有附加参数的自定义函数


基础教程推荐
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01