如何在我的Web服务器URL中隐藏.jsp扩展名 [英] How to hide the .jsp extension in my web server urls

查看:240
本文介绍了如何在我的Web服务器URL中隐藏.jsp扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP Web服务器,其页面均以.jsp扩展名结尾.

I have a JSP web server, with pages that all end with the .jsp extension.

如何在不借助非Java技巧(例如apache重写)的情况下将其隐藏在我的网络服务器网址中?

How can I hide it in my web server urls without resorting to non-java tricks (e.g., apache rewrite)?

例如: 而不是输入 http://www.sample.com/search.jsp?xxx 用户只需输入 http://www.sample.com/search?xxx

For example: instead of typing http://www.sample.com/search.jsp?xxx the user would just type http://www.sample.com/search?xxx

推荐答案

您可以创建一个servlet映射,如下所示:

You can create a servlet mapping like this:

<servlet-mapping>
   <servlet-name>MappingServlet</servlet-name>
   <url-pattern>path/*</url-pattern>
 </servlet-mapping>

必须编辑url模式以适合您的需求.当然,您需要创建servlet才能将url映射到实际的jsp.大多数MVC框架都使用这种技术.

The url-pattern must be edited to suit your needs. You need of course to create the servlet in order to map the url to the actual jsp. This technique is used by most of the MVC frameworks.

这篇关于如何在我的Web服务器URL中隐藏.jsp扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆