简体   繁体   English

Servlet。 映射规范?

[英]Servlet. Specification of Mappings?

Based on Java Servlet Specification Version 3.0 : 基于Java Servlet Specification Version 3.0

In the Web application deployment descriptor, the following syntax is used to define mappings: 在Web应用程序部署描述符中,以下语法用于定义映射:

A string beginning with a '/' character and ending with '/*' suffix is used for path mapping. 以'/'字符开头并以'/ *'后缀结尾的字符串用于路径映射。

A string beginning with '*.' 以“ *”开头的字符串。 prefix is used as an extension mapping. 前缀用作扩展名映射。

A string containing only the '/' character indicates the "default" servlet of the application. 仅包含“ /”字符的字符串表示应用程序的“默认” servlet。

All other strings are used for exact matches only. 所有其他字符串仅用于完全匹配。

so, I have next questions: 所以,我有下一个问题:

  1. How I can process this URL pattern: "/foo/bar/*.jsp"? 如何处理以下URL模式:“ / foo / bar / *。jsp”?

  2. What principal difference between '/*' and '/'? “ / *”和“ /”之间的主要区别是什么?

  1. Use less restrictive pattern (for example, /foo/bar/* ) and apply additional restrictions programmatically. 使用限制较少的模式(例如/foo/bar/* ),并以编程方式应用其他限制。

  2. / handles request only if its URL doesn't match any other mapping, whereas /* follows normal mapping precendence rules. /仅在其URL与任何其他映射都不匹配时才处理请求,而/*遵循常规映射优先规则。
    For example, if you map front controller of your application as /* you won't be able to render JSP pages, because /* takes precendence over built-in JSP servlet mapped to *.jsp . 例如,如果将应用程序的前端控制器映射为/* ,则将无法呈现JSP页面,因为/*优先于映射到*.jsp内置JSP servlet。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM