[英]What is the meaning of the leading slash / in Tomcat's <url-pattern>?
I know I cannot use regular expressions for the <url-pattern>
of a filter-mapping, but is it possible to use a directory pattern to specify any url containing the word myuniqws
as in: 我知道我不能对过滤器映射的
<url-pattern>
使用正则表达式,但是可以使用目录模式来指定任何包含单词myuniqws
url,如下所示:
https://my.hostname.org/myuniqws/myport/soap?wsdl
I am thinking of perhaps this would be the correct syntax: 我在想这也许是正确的语法:
<url-pattern>/*myuniqws*</url-pattern>
but I have not been able to find documentation for the exact rule of Tomcat's <url-pattern>
syntax. 但是我无法找到有关Tomcat
<url-pattern>
语法的确切规则的文档。
Will the above regex work as I desire? 上述正则表达式是否可以按我的意愿工作?
Update: 更新:
Thanks to the answer below, I discovered the following section in the Java Servlet Specification, which basically answers my questions. 感谢下面的回答,我发现了Java Servlet规范的以下部分,该部分基本上回答了我的问题。
12.2 Specification of Mappings 12.2映射规范
In the Web application deployment descriptor, the following syntax is used to define mappings: 在Web应用程序部署描述符中,以下语法用于定义映射:
http://host:port/<contextroot>/
. http://host:port/<contextroot>/
。 In this case the path info is '/' and the servlet path and context path is empty string (““). If the effective web.xml
(after merging information from fragments and annotations) contains any url-patterns that are mapped to multiple servlets then the deployment must fail. 如果有效的
web.xml
(合并来自片段和批注的信息之后)包含映射到多个servlet的任何url模式,则部署必须失败。
Presumably, you mean the <url-pattern>
for filter mappings in web.xml
. 大概是指
web.xml
过滤器映射的<url-pattern>
。 You might not know this, but web.xml
is defined as part of the Java Servlet Specification. 您可能不知道这一点,但是
web.xml
被定义为Java Servlet规范的一部分。 You can find full documentation for the 3.1 version (currently, the latest and greatest) here: 您可以在以下位置找到有关3.1版的完整文档(当前,最新和最好的):
https://jcp.org/aboutJava/communityprocess/final/jsr340/index.html https://jcp.org/aboutJava/communityprocess/final/jsr340/index.html
If you read section 12.2 ("Specification of Mappings") you can see exactly what kinds of patterns are recognized, including the prefix-mapping you are requesting above. 如果您阅读了第12.2节(“映射的规范”),则可以确切地看到可以识别哪些类型的模式,包括您在上面请求的前缀映射。
EDIT 2014-11-04 : You should know that CATALINA_HOME/conf/web.xml
(or CATALINA_BASE/conf/web.xml
if you have one) is the default configuration for all web applications deployed on Tomcat and that your webapp's WEB-INF/web.xml
is the configuration specific for your own web application. 编辑2014-11-04 :您应该知道
CATALINA_HOME/conf/web.xml
(如果有的话,也可以是CATALINA_BASE/conf/web.xml
)是在Tomcat上部署的所有Web应用程序的默认配置,并且您的WEB-INF/web.xml
应用程序是WEB-INF/web.xml
是特定于您自己的Web应用程序的配置。 Both of these files should have the following xmlns
statements and therefore indicate to you (by their URIs) that they are covered by the Java Servlet Specification (or at least Java EE, which includes the servlet spec): 这两个文件都应具有以下
xmlns
语句,因此(通过它们的URI)向您表明它们已被Java Servlet规范(或至少包括Servlet规范的Java EE)所涵盖:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.