This commit is contained in:
@@ -105,34 +105,37 @@ public final class HttpPrepareServlet extends PrepareServlet<String, HttpContext
|
|||||||
if (!ws.repair()) prefix = "";//被设置为自动追加前缀则清空prefix
|
if (!ws.repair()) prefix = "";//被设置为自动追加前缀则清空prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String mapping : mappings) {
|
synchronized (mapStrings) {
|
||||||
if (!prefix.toString().isEmpty()) mapping = prefix + mapping;
|
for (String mapping : mappings) {
|
||||||
if (this.mapStrings.containsKey(mapping)) {
|
if(mapping == null) continue;
|
||||||
Class old = this.mapStrings.get(mapping);
|
if (!prefix.toString().isEmpty()) mapping = prefix + mapping;
|
||||||
throw new RuntimeException("mapping [" + mapping + "] repeat on " + old.getName() + " and " + servlet.getClass().getName());
|
if (this.mapStrings.containsKey(mapping)) {
|
||||||
}
|
Class old = this.mapStrings.get(mapping);
|
||||||
if (contains(mapping, '.', '*', '{', '[', '(', '|', '^', '$', '+', '?', '\\')) { //是否是正则表达式))
|
throw new RuntimeException("mapping [" + mapping + "] repeat on " + old.getName() + " and " + servlet.getClass().getName());
|
||||||
if (mapping.charAt(0) != '^') mapping = '^' + mapping;
|
|
||||||
if (mapping.endsWith("/*")) {
|
|
||||||
mapping = mapping.substring(0, mapping.length() - 1) + ".*";
|
|
||||||
} else {
|
|
||||||
mapping = mapping + "$";
|
|
||||||
}
|
}
|
||||||
if (regArray == null) {
|
if (contains(mapping, '.', '*', '{', '[', '(', '|', '^', '$', '+', '?', '\\')) { //是否是正则表达式))
|
||||||
regArray = new SimpleEntry[1];
|
if (mapping.charAt(0) != '^') mapping = '^' + mapping;
|
||||||
regArray[0] = new SimpleEntry<>(Pattern.compile(mapping).asPredicate(), servlet);
|
if (mapping.endsWith("/*")) {
|
||||||
} else {
|
mapping = mapping.substring(0, mapping.length() - 1) + ".*";
|
||||||
regArray = Arrays.copyOf(regArray, regArray.length + 1);
|
} else {
|
||||||
regArray[regArray.length - 1] = new SimpleEntry<>(Pattern.compile(mapping).asPredicate(), servlet);
|
mapping = mapping + "$";
|
||||||
|
}
|
||||||
|
if (regArray == null) {
|
||||||
|
regArray = new SimpleEntry[1];
|
||||||
|
regArray[0] = new SimpleEntry<>(Pattern.compile(mapping).asPredicate(), servlet);
|
||||||
|
} else {
|
||||||
|
regArray = Arrays.copyOf(regArray, regArray.length + 1);
|
||||||
|
regArray[regArray.length - 1] = new SimpleEntry<>(Pattern.compile(mapping).asPredicate(), servlet);
|
||||||
|
}
|
||||||
|
} else if (mapping != null && !mapping.isEmpty()) {
|
||||||
|
super.mappings.put(mapping, servlet);
|
||||||
}
|
}
|
||||||
} else if (mapping != null && !mapping.isEmpty()) {
|
this.mapStrings.put(mapping, servlet.getClass());
|
||||||
super.mappings.put(mapping, servlet);
|
|
||||||
}
|
}
|
||||||
this.mapStrings.put(mapping, servlet.getClass());
|
setServletConf(servlet, conf);
|
||||||
|
servlet._prefix = prefix.toString();
|
||||||
|
this.servlets.add(servlet);
|
||||||
}
|
}
|
||||||
setServletConf(servlet, conf);
|
|
||||||
servlet._prefix = prefix.toString();
|
|
||||||
this.servlets.add(servlet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean contains(String string, char... values) {
|
private static boolean contains(String string, char... values) {
|
||||||
|
|||||||
Reference in New Issue
Block a user