我尝试配置jetty上下文(以编程方式)使用服务根上下文的servlet。空上下文字符串警告
对于上下文路径,我设置“/”和servlet映射“/ *”。这完全按照我想要的方式工作,但Jetty抱怨(警告)以'/'结尾的上下文路径。当我将上下文路径设置为“”(空字符串)时,会产生一个关于空字符串的警告。
的documentation section of Jetty有关此问题的状态:
注意
Java Servlet规范2.5阻碍空上下文路径字符串,以及Java Servlet规范3.0有效地禁止它。
防波堤源的部分是:
public void setContextPath(String contextPath)
{
if (contextPath == null)
throw new IllegalArgumentException("null contextPath");
if (contextPath.endsWith("/*"))
{
LOG.warn(this+" contextPath ends with /*");
contextPath=contextPath.substring(0,contextPath.length()-2);
}
else if (contextPath.endsWith("/"))
{
LOG.warn(this+" contextPath ends with /");
contextPath=contextPath.substring(0,contextPath.length()-1);
}
if (contextPath.length()==0)
{
LOG.warn("Empty contextPath");
contextPath="/";
}
_contextPath = contextPath;
if (getServer() != null && (getServer().isStarting() || getServer().isStarted()))
{
Handler[] contextCollections = getServer().getChildHandlersByClass(ContextHandlerCollection.class);
for (int h = 0; contextCollections != null && h < contextCollections.length; h++)
((ContextHandlerCollection)contextCollections[h]).mapContexts();
}
}
所以,问题是,什么情况下的路径应我为了映射到上下文的根设置。目前一切正常,但有规范或Jetty警告禁止上下文路径设置,我想我需要不同的东西。
忽略警告? – Kayaman
会是不好的风格:) –
你必须是新的业务。 – Kayaman