何时使用@QueryParam vs @PathParam(When to use @QueryParam vs @PathParam)
我没有问过这个问题: @PathParam和@QueryParam有什么区别?
这是一个“最佳做法”或惯例问题。
什么时候使用
@PathParam
vs@QueryParam
。我可以想到的决定可能是使用这两种来区分信息模式。 让我在下面说明我的LTPO - 不太完美的观察。
PathParam使用可以保留用于信息类别,这将很好地落入信息树的一个分支。 PathParam可用于深入实体类层次结构。
而QueryParam可以被保留用于指定属性来定位类的实例。
例如,
/Vehicle/Car?registration=123
/House/Colonial?region=newengland
/category?instance
@GET @Path("/employee/{dept}") Patient getEmployee(@PathParam("dept")Long dept, @QueryParam("id")Long id) ;
vs
/category/instance
@GET @Path("/employee/{dept}/{id}") Patient getEmployee(@PathParam("dept")Long dept, @PathParam("id")Long id) ;
vs
?category+instance
@GET @Path("/employee") Patient getEmployee(@QueryParam("dept")Long dept, @QueryParam("id")Long id) ;
我不认为有这样做的标准惯例。 在那儿? 不过,我想听听人们如何使用PathParam和QueryParam来区分他们的信息,就像上面的例子。 我也很乐意听到这个做法背后的原因。
I am not asking the question that is already asked here: What is the difference between @PathParam and @QueryParam
This is a "best practices" or convention question.
When would you use
@PathParam
vs@QueryParam
.What I can think of that the decision might be using the two to differentiate the information pattern. Let me illustrate below my LTPO - less than perfect observation.
PathParam use could be reserved for information category, which would fall nicely into a branch of an information tree. PathParam could be used to drill down to entity class hierarchy.
Whereas, QueryParam could be reserved for specifying attributes to locate the instance of a class.
For example,
/Vehicle/Car?registration=123
/House/Colonial?region=newengland
/category?instance
@GET @Path("/employee/{dept}") Patient getEmployee(@PathParam("dept")Long dept, @QueryParam("id")Long id) ;
vs
/category/instance
@GET @Path("/employee/{dept}/{id}") Patient getEmployee(@PathParam("dept")Long dept, @PathParam("id")Long id) ;
vs
?category+instance
@GET @Path("/employee") Patient getEmployee(@QueryParam("dept")Long dept, @QueryParam("id")Long id) ;
I don't think there is a standard convention of doing it. Is there? However, I would like to hear of how people use PathParam vs QueryParam to differentiate their information like I exemplified above. I would also love to hear the reason behind the practice.
原文:https://stackoverflow.com/questions/11552248
相关问答
更多-
重命名MySQL中的一列(Rename a column in MySQL)[2022-08-16]
使用以下查询: ALTER TABLE tableName CHANGE `oldcolname` `newcolname` datatype(length); RENAME函数在Oracle数据库中使用。 ALTER TABLE tableName RENAME COLUMN "oldcolname" TO "newcolname" datatype(length); 注意用于MySQL的反引号,而双引号用于Oracle的语法 Use the following query: ALTER TABLE ... -
有什么数据库专业书籍介绍?[2022-05-19]
mysql -
你使用set_index有或没有set_index inplace=True df.set_index(df.File.radd(df.index.astype(str) + '_')) Start File File 0_a 0 a 1_a 1 a 2_a 2 a 3_a 2 a 4_b 0 b 5_b 1 b 6_b 2 b 7_b 2 b 8 ...
-
根据http://codingforums.com/showthread.php?t=148936 ,您可能需要解析SHOW CREATE TABLE的结果以获取当前定义,然后在ALTER语句中使用该定义。 mysql_fetch_field()也可能有用。 According to http://codingforums.com/showthread.php?t=148936, you may have to parse the results of SHOW CREATE TABLE to get th ...
-
MySQL重命名列(MySQL rename column)[2022-08-18]
不,你做得对。 ALTER用于更改现有数据库对象(例如表的名称 - 它是数据定义语句(DDL))。 使用AS为结果提供别名,因此该语句: SELECT COUNT(*) AS num FROM TABLE_A 将计算表中的行数,并将结果输出到名为num的列中。 请注意,除非您指定计数,否则计数不适用于不同的行,或者使用group by子句,因此如果存在重复行,则它们都将被计算。 No, you've got it right. ALTERis used to change existing databas ... -
无法重命名索引。 随意在Azure Search UserVoice网站上添加建议。 It's not possible to rename an index. Feel free to add a suggestion on Azure Search UserVoice site.
-
我不确定MySQL是否允许首先为主键命名。 虽然似乎有一种语法: CREATE TABLE test ( test_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, CONSTRAINT my_test_pk PRIMARY KEY (test_id) ) ENGINE=InnoDB; ...它没有显示在information_schema.TABLE_CONSTRAINTS或我能发现的任何其他地方,所以我的印象是它只是默默地丢弃了。 您看到的名称可 ...
-
重命名索引的最佳方法(Best way to rename indexes)[2024-04-22]
sp_rename将正常工作,不应该破坏任何东西,除非您在查询提示中的某个地方引用了当前名称。 sp_rename will work fine and shouldn't break anything unless you have queries somewhere that reference the current name(s) in a query hint. -
无法重命名mysql表(can't rename mysql table)[2024-02-14]
它就是MySQL如何在Windows上运行: http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_lower_case_table_names 的lower_case_table_names 如果设置为0,则表名称按指定存储,并且比较区分大小写。 如果设置为1,则表名称以小写形式存储在磁盘上,并且比较不区分大小写。 如果设置为2,则表名存储为给定但以小写形式进行比较。 此选项也适用于数据库名称和表别名。 有关其 ... -
SQLite的ALTER TABLE不支持此功能。 只需重新创建它: DROP INDEX old_index; CREATE INDEX new_index ON demo([...]); 您可以从架构中获取索引定义: SELECT sql FROM sqlite_master WHERE type = 'index' AND name = 'old_index'; 但是没有机制可以从SQLite内部修改和执行结果。 SQLite's ALTER TABLE does not support this ...