This commit is contained in:
wentch
2015-12-29 15:28:01 +08:00
parent 5f8461bf8d
commit e4bb4cbaab
5 changed files with 8 additions and 7 deletions

View File

@@ -135,14 +135,14 @@
<!--
加载所有的Servlet服务;
prefix: servlet的ContextPath前缀 默认为空
path: servlet的ContextPath前缀 默认为空
autoload="true" 默认值. 自动加载以下目录如果存在的话下所有的Servlet类:
${APP_HOME}/lib; ${APP_HOME}/root/lib/*; ${APP_HOME}/root/classes;
autoload="false" 需要显著的指定Service类
includes 当autoload="true" 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
excludes 当autoload="true" 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
-->
<servlets prefix="/pipes" autoload="true" includes="" excludes="">
<servlets path="/pipes" autoload="true" includes="" excludes="">
<!--
当Server为HTTP协议时ResourceServlet才有效. 默认存在一个有默认属性的resource-servlet节点
webroot: web资源的根目录, 多个目录用;分隔请求页面url时如果第一个目录不存在则会查询下一个目录是否存在该文件至到所有目录集合 默认取server节点中的root值

View File

@@ -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];
}

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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 {};