This commit is contained in:
Redkale
2016-08-15 11:32:12 +08:00
parent 5f1556e5cb
commit a3681ca698

View File

@@ -31,7 +31,7 @@ public abstract class BasedHttpServlet extends HttpServlet {
/** /**
* 配合 BasedHttpServlet 使用。 * 配合 BasedHttpServlet 使用。
* 当标记为 @AuthIgnore 的方法不会再调用之前调用authenticate 方法。 * 当标记为 @AuthIgnore 的方法在执行execute之前不会调用authenticate 方法。
* *
* <p> * <p>
* 详情见: http://redkale.org * 详情见: http://redkale.org
@@ -48,7 +48,7 @@ public abstract class BasedHttpServlet extends HttpServlet {
/** /**
* 配合 BasedHttpServlet 使用。 * 配合 BasedHttpServlet 使用。
* 用于对&#64;WebServlet对应的url进行细分。 其 url * 用于对&#64;WebServlet对应的url进行细分。 其url必须是包含WebServlet中定义的前缀 且不能是正则表达式
* *
* <p> * <p>
* 详情见: http://redkale.org * 详情见: http://redkale.org
@@ -129,6 +129,8 @@ public abstract class BasedHttpServlet extends HttpServlet {
for (Map.Entry<String, Entry> en : map.entrySet()) { for (Map.Entry<String, Entry> en : map.entrySet()) {
actions[++i] = new AbstractMap.SimpleEntry<>(path + en.getKey(), en.getValue()); actions[++i] = new AbstractMap.SimpleEntry<>(path + en.getKey(), en.getValue());
} }
//必须要倒排序, /query /query1 /query12 确保含子集的优先匹配 /query12 /query1 /query
Arrays.sort(actions, (o1, o2) -> o2.getKey().compareTo(o1.getKey()));
} }
public final void postDestroy(HttpContext context, AnyValue config) { public final void postDestroy(HttpContext context, AnyValue config) {
@@ -161,11 +163,12 @@ public abstract class BasedHttpServlet extends HttpServlet {
final String name = action.url().trim(); final String name = action.url().trim();
if (nameset.contains(name)) throw new RuntimeException(this.getClass().getSimpleName() + " has two same " + WebAction.class.getSimpleName() + "(" + name + ")"); if (nameset.contains(name)) throw new RuntimeException(this.getClass().getSimpleName() + " has two same " + WebAction.class.getSimpleName() + "(" + name + ")");
for (String n : nameset) { //屏蔽以下代码,允许相互包含
if (n.contains(name) || name.contains(n)) { // for (String n : nameset) {
throw new RuntimeException(this.getClass().getSimpleName() + " has two sub-contains " + WebAction.class.getSimpleName() + "(" + name + ", " + n + ")"); // if (n.contains(name) || name.contains(n)) {
} // throw new RuntimeException(this.getClass().getSimpleName() + " has two sub-contains " + WebAction.class.getSimpleName() + "(" + name + ", " + n + ")");
} // }
// }
nameset.add(name); nameset.add(name);
map.put(name, new Entry(typeIgnore, serviceid, actionid, name, method, createHttpServlet(method))); map.put(name, new Entry(typeIgnore, serviceid, actionid, name, method, createHttpServlet(method)));
} }