This commit is contained in:
Redkale
2017-05-23 13:15:13 +08:00
parent f18ef4f94d
commit 6f4c9dca48
3 changed files with 21 additions and 1 deletions

View File

@@ -142,6 +142,12 @@ public final class Rest {
//------------------------------------------------------------------------------
final String defmodulename = getWebModuleName(serviceType);
final String catalog = controller == null ? "" : controller.catalog();
for (char ch : catalog.toCharArray()) {
if (!((ch >= '0' && ch <= '9') || ch == '$' || ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { //不能含特殊字符
throw new RuntimeException(serviceType.getName() + " have illeal " + RestService.class.getSimpleName() + ".catalog, only 0-9 a-z A-Z _ $");
}
}
for (char ch : defmodulename.toCharArray()) {
if (!((ch >= '0' && ch <= '9') || ch == '$' || ch == '_' || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { //不能含特殊字符
throw new RuntimeException(serviceType.getName() + " have illeal " + RestService.class.getSimpleName() + ".value, only 0-9 a-z A-Z _ $");
@@ -162,7 +168,7 @@ public final class Rest {
}
{ //注入 @WebServlet 注解
String urlpath = "/" + defmodulename + "/*";
String urlpath = (catalog.isEmpty() ? "/" : ("/" + catalog + "/")) + defmodulename + "/*";
int moduleid = controller == null ? 0 : controller.moduleid();
boolean repair = controller == null ? true : controller.repair();
String comment = controller == null ? "" : controller.comment();

View File

@@ -29,6 +29,13 @@ public @interface RestService {
*/
String name() default "";
/**
* 目录名, 不能含特殊字符, 只能小写字母+数字,且不能以数字开头
*
* @return 目录名
*/
String catalog() default "";
/**
* 模块ID值鉴权时用到, 对应&#64;WebServlet.moduleid
*

View File

@@ -29,6 +29,13 @@ public @interface RestWebSocket {
*/
String name() default "";
/**
* 目录名, 不能含特殊字符, 只能小写字母+数字,且不能以数字开头
*
* @return 目录名
*/
String catalog() default "";
/**
* 是否屏蔽该类的转换
*