`
ruruhuang
  • 浏览: 193058 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

How are Servlet paths mapped?

阅读更多
补充点基础知识. Path mappings are used to map a URI to a contexts, handlers and servlets.

The following types of mapping are supported and applied in the order presented.

Absolute Mapping
Path Spec:      /path

Will match: /path path=/path info=<null>

Will not match: / /path/ /path/info /path/info.jsp /other
Prefix Mapping
Path Spec:      /path/*

Will match: /path path=/path info=<null> /path/ path=/path info=/ /path/info path=/path info=/info /path/info.jsp path=/path info=/info.jsp

Will not match: / /other
Suffix Mapping
Path Spec:      *.jsp

Will match: /path/info.jsp path=info=/path/info.jsp

Will not match: / /path /path/ /path/info /other
Default Mapping
Path Spec:      /

Will match: / path= info=/ /path path= info=/path /path/ path= info=/path/ /path/info path= info=/path/info /path/info.jsp path= info=/path/info.jsp /other path= info=/other

Will not match:

Typical examples

Context and Servlet with path
  Context Path Spec :    /context/*  Servlet Path Spec :    /servlet/*

URI ContextPath ServletPath PathInfo ========================================================= /context/servlet /context /servlet null /context/servlet/ /context /servlet / /context/servlet/x /context /servlet /x


Default Context
  Context Path Spec :    /  Servlet Path Spec :    /servlet/*

URI ContextPath ServletPath PathInfo ========================================================= /servlet "" /servlet null /servlet/ "" /servlet / /servlet/x "" /servlet /x


Context and Suffix Servlet
  Context Path Spec :    /context/*  Servlet Path Spec :    *.txt

URI ContextPath ServletPath PathInfo ========================================================= /context/xxx.txt /context "" /xxx.txt


Context and Default Servlet
  Context Path Spec :    /context/*  Servlet Path Spec :    /

URI ContextPath ServletPath PathInfo ========================================================= /context/xxx /context "" /xxx


Default Context and Servlet
  Context Path Spec :    /  Servlet Path Spec :    /

URI ContextPath ServletPath PathInfo ========================================================= /xxx "" "" /xxx
来自:http://jetty.mortbay.org/jetty/faq?s=500-Servlets&t=Path%20Mapping
分享到:
评论

相关推荐

    Android代码-复制路径到剪切板

    Need to copy file paths often? If yes, the Android app is developed for you. Try it! How to use? Download and install it. Share/Send the target file to Path Copier. OK. Notice that, the app has no ...

    servlet2.4doc

    Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. destroy() - Method in class javax.servlet.GenericServlet Called by the servlet container to ...

    jsp+servlet头像上传功能

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 验证文件类型和大小 // ... // 保存文件到服务器 File uploadedFile = new File("/path/to/uploaded/images/" ...

    servlet整合ckeditor编辑器

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); File uploadedFile = new File("uploads/" + fileName); filePart.write(uploadedFile.getAbsolutePath()); // 返回...

    servlet3.0-demo

    String fileName = Paths.get(part.getSubmittedFileName()).getFileName().toString(); part.write("uploads/" + fileName); } response.getWriter().write("File uploaded successfully."); } ``` 在这个例子...

    A Course on Rough Paths

    theory of rough paths, but rather to complement the existing literature on the subject. As a consequence, there are a number of aspects that we chose not to touch, or to do so only barely. One ...

    ajax异步文件上传,servlet处理

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 将文件保存到服务器的指定位置 File uploadedFile = new File("/path/to/save/uploaded/files", fileName); ...

    jsp+servlet文件上传

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); File uploadedFile = new File("/path/to/save/uploaded/files/" + fileName); filePart.write(uploadedFile....

    servlet上传下载文件

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 获取文件名 InputStream fileContent = filePart.getInputStream(); // 获取文件输入流 // 存储文件到服务器的...

    Ember.Data.in.the.Wild.Getting.Ember.Data.to.Work.With.Your.API

    Have a custom API that you aren't sure how to use with Ember Data? Interested in writing your own adapter or serializer? Want to just know more about how Ember Data works? This is the Ember Data book ...

    servlet 上传文件流保存到数据库

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 获取文件名 } ``` 接收到文件后,我们需要将其转换为字节数组,以便存储在数据库中。可以使用`InputStream`和`...

    Servlet中文件上传和下载

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 获取文件名 FileItemStream item = new DiskFileItemFactory().createItem("file", filePart.getContentType(), ...

    Profiling all paths

    - **Acyclic Paths:** These are paths that do not contain any loops. Existing profiling techniques have been effective in analyzing these paths. - **Cyclic Paths:** These involve loops, which can be ...

    Java servlet 和 swf上传超大文件源码

    String fileName = Paths.get(item.getName()).getFileName().toString(); File uploadedFile = new File("/path/to/save", fileName); item.write(uploadedFile); } } } ``` **SWFUpload介绍** SWFUpload是...

    servlet实现文件上传功能

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 获取文件名 // 将文件保存到服务器 File uploadedFile = new File("/path/to/save/" + fileName); Files.copy...

    简单的文件上传 (servlet)

    String fileName = Paths.get(part.getSubmittedFileName()).getFileName().toString(); // 写入文件到服务器 part.write("/path/to/save/" + fileName); } response.getWriter().write("文件上传成功!"); }...

    servlet+jquery实现文件上次进度条

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); File uploadedFile = new File("/path/to/save/" + fileName); filePart.write(uploadedFile.getAbsolutePath()); ...

    Servlet使用jquery.uploadify上传附件

    String fileName = Paths.get(filePart.getSubmittedFileName()).getFileName().toString(); // 保存文件到服务器的某个目录 File savedFile = new File("uploads/" + fileName); filePart.write(savedFile....

    Expert.Oracle.Indexing.and.Access.Paths.2nd.epub

    Expert Oracle Indexing and Access Paths helps by bringing together information on indexing and how to use it into one blissfully short volume that you can read quickly and have at your fingertips for...

    Servlet实现资源的上传与下载

    String fileName = Paths.get(item.getName()).getFileName().toString(); if (!item.isFormField()) { // 处理文件流并保存到服务器 } } } ``` #### 3. 保存上传的文件 在Servlet中,从`FileItemStream`获取...

Global site tag (gtag.js) - Google Analytics