不含#且方法不超过6个的RestService转换RestServlet采用枚举方式列出@WebServlet.value
This commit is contained in:
@@ -779,7 +779,14 @@ public final class Rest {
|
|||||||
av0 = cw.visitAnnotation(webServletDesc, true);
|
av0 = cw.visitAnnotation(webServletDesc, true);
|
||||||
{
|
{
|
||||||
AnnotationVisitor av1 = av0.visitArray("value");
|
AnnotationVisitor av1 = av0.visitArray("value");
|
||||||
if (defmodulename.isEmpty()) {
|
boolean pound = false;
|
||||||
|
for (MappingEntry entry : entrys) {
|
||||||
|
if (entry.existsPound) {
|
||||||
|
pound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defmodulename.isEmpty() || (!pound && entrys.size() <= 6)) {
|
||||||
for (MappingEntry entry : entrys) {
|
for (MappingEntry entry : entrys) {
|
||||||
String suburl = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defmodulename.isEmpty() ? "" : (defmodulename + "/")) + entry.name;
|
String suburl = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + (defmodulename.isEmpty() ? "" : (defmodulename + "/")) + entry.name;
|
||||||
urlpath += "," + suburl;
|
urlpath += "," + suburl;
|
||||||
@@ -1821,6 +1828,22 @@ public final class Rest {
|
|||||||
this.actionid = mapping.actionid();
|
this.actionid = mapping.actionid();
|
||||||
this.cacheseconds = mapping.cacheseconds();
|
this.cacheseconds = mapping.cacheseconds();
|
||||||
this.comment = mapping.comment();
|
this.comment = mapping.comment();
|
||||||
|
boolean pound = false;
|
||||||
|
Parameter[] params = method.getParameters();
|
||||||
|
for (Parameter param : params) {
|
||||||
|
RestParam rp = param.getAnnotation(RestParam.class);
|
||||||
|
if (rp != null && !rp.name().isEmpty() && rp.name().charAt(0) == '#') {
|
||||||
|
pound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!pound && params.length == 1) {
|
||||||
|
Class ptype = method.getParameterTypes()[0];
|
||||||
|
if (this.name.startsWith("find") || this.name.startsWith("delete")) {
|
||||||
|
if (ptype.isPrimitive() || ptype == String.class) pound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.existsPound = pound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int methodidx; // _paramtypes 的下标,从0开始
|
public final int methodidx; // _paramtypes 的下标,从0开始
|
||||||
@@ -1841,6 +1864,8 @@ public final class Rest {
|
|||||||
|
|
||||||
public final int cacheseconds;
|
public final int cacheseconds;
|
||||||
|
|
||||||
|
public final boolean existsPound; //是否包含#的参数
|
||||||
|
|
||||||
@RestMapping()
|
@RestMapping()
|
||||||
void mapping() { //用于获取Mapping 默认值
|
void mapping() { //用于获取Mapping 默认值
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user