This commit is contained in:
@@ -99,7 +99,7 @@ public final class NodeHttpServer extends NodeServer {
|
||||
|
||||
protected void loadHttpServlet(final AnyValue conf, final ClassFilter<? extends Servlet> filter) throws Exception {
|
||||
final StringBuilder sb = logger.isLoggable(Level.FINE) ? new StringBuilder() : null;
|
||||
final String prefix = conf == null ? "" : conf.getValue("prefix", "");
|
||||
final String prefix = conf == null ? "" : conf.getValue("path", "");
|
||||
final String threadName = "[" + Thread.currentThread().getName() + "] ";
|
||||
List<FilterEntry<? extends Servlet>> list = new ArrayList(filter.getFilterEntrys());
|
||||
list.sort((FilterEntry<? extends Servlet> o1, FilterEntry<? extends Servlet> o2) -> { //必须保证WebSocketServlet优先加载, 因为要确保其他的HttpServlet可以注入本地模式的WebSocketNode
|
||||
@@ -117,7 +117,7 @@ public final class NodeHttpServer extends NodeServer {
|
||||
final HttpServlet servlet = clazz.newInstance();
|
||||
factory.inject(servlet, this);
|
||||
String[] mappings = ws.value();
|
||||
if (ws.fillurl() && !prefix.isEmpty()) {
|
||||
if (ws.repair() && !prefix.isEmpty()) {
|
||||
for (int i = 0; i < mappings.length; i++) {
|
||||
mappings[i] = prefix + mappings[i];
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class BasedHttpServlet extends HttpServlet {
|
||||
public void init(Context context, AnyValue config) {
|
||||
String path = ((HttpContext) context).getContextPath();
|
||||
WebServlet ws = this.getClass().getAnnotation(WebServlet.class);
|
||||
if (ws != null && !ws.fillurl()) path = "";
|
||||
if (ws != null && !ws.repair()) path = "";
|
||||
HashMap<String, Entry> map = load();
|
||||
this.actions = new Map.Entry[map.size()];
|
||||
int i = -1;
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class HttpServer extends Server {
|
||||
public void init(AnyValue config) throws Exception {
|
||||
super.init(config);
|
||||
AnyValue conf = config == null ? null : config.getAnyValue("servlets");
|
||||
this.contextPath = conf == null ? "" : conf.getValue("prefix", "");
|
||||
this.contextPath = conf == null ? "" : conf.getValue("path", "");
|
||||
}
|
||||
|
||||
public void addHttpServlet(HttpServlet servlet, AnyValue conf, String... mappings) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 功能同JSR 315 (java-servlet 3.0) 规范中的 @WebServlet
|
||||
*
|
||||
*
|
||||
* @see http://www.redkale.org
|
||||
* @author zhangjx
|
||||
*/
|
||||
@@ -20,7 +21,7 @@ public @interface WebServlet {
|
||||
|
||||
String name() default "";
|
||||
|
||||
boolean fillurl() default true;
|
||||
boolean repair() default true;
|
||||
|
||||
String[] value() default {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user