- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个与 servlet 映射有关的问题。我在 web.xml 中有以下内容:
<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>test.HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
如果我访问 http://localhost:<port>/MyApp/HelloWorld
servlet HelloWorldServlet
被调用。
我还希望我的 serverlet 响应 http://localhost:<port>/MyApp/HelloWorld/
.我怎样才能达到这个效果?我正在使用 NetBeans 进行开发,但它不允许我放置以 /
结尾的模式.
最佳答案
在您的 <url-pattern>
添加通配符后
<url-pattern>/HelloWorld/*</url-pattern>
您可以使用 HttpServletRequest.getPathInfo()
获取与 URL 关联的额外路径.
例如
http://localhost:<port>/MyApp/HelloWorld/one/
结果将是
/one/
来自 JavaDoc:
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character.
关于java - Servlet 映射 : url-pattern for URLs with trailing slash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4377541/
刚刚开始了一份新工作,公司的网站是建立在WordPress上的。所有URL似乎都有一个尾随反斜杠,例如https://www.digitallearninginstitute.com/courses/
我有以下形式的文件名:/folder/file.jpg,我想通过删除任何额外的正斜杠来清理它。 例如: '/tt////Images/WP1213.jpg' => '/tt/Images/WP1213
当前删除多条斜线的代码是 path = path.replaceAll("/{2,}", "/"); 这变成了https://stackoverflow.com到 https:/stackoverfl
我正在尝试构建一个正则表达式来匹配两个正斜杠之间的正则表达式。我的主要问题是正则表达式本身可以包含正斜杠,由反斜杠转义。我尝试用否定的后视断言过滤掉它们(如果当前位置没有反冲,则只匹配结束斜杠),但是
我正在尝试匹配 url 中不属于协议(protocol)或查询字符串一部分的斜杠后跟斜杠。 是否有任何其他方法可以使用 REGEX 来执行此操作,但由于并非所有浏览器都支持它,因此无需回顾? 我的例子
使用键盘快捷键注释或取消注释代码 ⌘+/ 时,我遇到了 Xcode 非常不可靠的问题。我似乎找不到关于它何时中断的真正模式,但它通常发生在模拟器上构建并运行我的代码之后。除非我在任何一个代码文件中编辑
我已经在许多 JavaScript 库中看到过它(例如 transducers-js 、 routex 和 redux )。我想这是命名空间的一种形式,但我在任何地方都找不到解释或至少对此发表评论。
如何替换字符串中重复的“斜杠”? 例如, str = '/estate//info//'; alert(fragment.replace(/\/\/+/, "/")); 结果, /estate/in
我正在开发的一个应用程序涉及访问网络文件共享上的文件,我们使用 URI 来指定文件的位置。 我对文件的理解:URI应该是file://+path的形式。在 Windows 网络共享的情况下,此路径类似
我今天安装了Homebrew,并按照应用程序的建议运行了 brew doctor 我收到此警告: Warning: Some directories in your path end in a sla
我想要斜线命令以表格格式输出数据? 我知道我必须为此设置自定义集成。我使用 GET 方法做到了这一点。 我可以在 EC2 机器上设置我自己的 Web 服务,但是我应该如何确保数据以表格格式出现。 可能
我正在使用 .htaccess 文件将目录请求定向到提供有关该目录的信息的自定义 php 文件(我希望浏览器显示的 url 不会更改)。 这是 .htaccess 文件的相关部分。 RewriteCo
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我有一个正则表达式来格式化 HTML 输入中的 URL。我想删除所有非字母或数字的字符。 所以我写了这个正则表达式: return url.toLowerCase() .rep
我已经通过 slash commands 从 slack 自动化了 Jenkins 中的部署. 我需要给permission for slash commands或者将斜杠命令访问限制为仅特定用户(即
如果我在 uri /myapp 下运行 Web 应用程序,那么一旦通过 http://example.com/myapp 访问该应用程序,URL 就会更改为http://example.com/mya
我需要发送 JSON 格式的日期。日期字符串应如下所示: "2013/5/15" 相反,JSONObject.toString 将其转义如下: "2013\ /5\ /15" 我知道这样做是为了允许脚
我有一个这样的路由器: routes: [ { path: '/survey/:surveyHash', name: 'survey', component
假设我想引用 最年轻提交的父级,其提交消息包含“foo”。 HEAD^{/foo}^会完成这项工作的。 这可以稍微缩短为 @^{/foo}^ (我认为)。 ^{/}不过,构造有一个简化的形式::/ .
在 Bootstrap 3 中,面包屑元素之间有默认的斜杠 (/) 符号。如何删除它?我想用“>”替换“/”。 代码片段: Home> Library> Data 我的代码演示 her
我是一名优秀的程序员,十分优秀!