web应用URL访问入口如何不区分大小写

gzc145 2014-06-09 09:59:10
如何实现同一个应用可以用
http://localhost:8080/test/
http://localhost:8080/TEST/ 都可以访问?
...全文
946 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
gzc145 2014-06-11
  • 打赏
  • 举报
回复
引用 15 楼 magi1201 的回复:
楼主先别结贴,再坚持几天。 应该有更好的办法的,像我们平时访问百度时,www.baidu.com 和 WWW.BAIDU.COM 都一样可以得到结果。 看看哪天有大牛路过时给一些好的提议,解决方案。
坚持坚持,哈哈!
姜小白- 2014-06-11
  • 打赏
  • 举报
回复
引用 18 楼 shine333 的回复:
[quote=引用 3 楼 yufengdxw 的回复:] 参考http://liuxiangdong100.blog.163.com/blog/static/22619438201012562519448/
<context>里面caseSensitive="false"是个办法,不过:只针对6以下,7开始已经完全抛弃了这个参数,理由是有严重安全问题 http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Standard_Implementation

Deprecated. This option is removed in Tomcat 7 onwards where the default of true is always used.

If the value of this flag is false, all case sensitivity checks will be disabled. If not specified, the default value of the flag is true.

NOTE: This flag MUST NOT be set to false on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.
注意:这个标志禁止在Windows(和其他不区分大小写的文件系统)上设置成false。因为这会导致JSP源代码的暴露和其他安全问题。[/quote] 大牛,你太厉害了。难怪我昨晚在家试上面的方法,发现不起作用。原来7开始已经完全抛弃了这个参数了
shine333 2014-06-11
  • 打赏
  • 举报
回复
LZ可以考虑URL Rewrite
shine333 2014-06-11
  • 打赏
  • 举报
回复
比如,人家可以通过index.JSP,来直接读取index.jsp源文件,而不是它生成的HTML。
shine333 2014-06-11
  • 打赏
  • 举报
回复
引用 3 楼 yufengdxw 的回复:
参考http://liuxiangdong100.blog.163.com/blog/static/22619438201012562519448/
<context>里面caseSensitive="false"是个办法,不过:只针对6以下,7开始已经完全抛弃了这个参数,理由是有严重安全问题 http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Standard_Implementation

Deprecated. This option is removed in Tomcat 7 onwards where the default of true is always used.

If the value of this flag is false, all case sensitivity checks will be disabled. If not specified, the default value of the flag is true.

NOTE: This flag MUST NOT be set to false on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.
注意:这个标志禁止在Windows(和其他不区分大小写的文件系统)上设置成false。因为这会导致JSP源代码的暴露和其他安全问题。
Mr-稻帅 2014-06-11
  • 打赏
  • 举报
回复
引用 3 楼 yufengdxw 的回复:
参考http://liuxiangdong100.blog.163.com/blog/static/22619438201012562519448/
正解呀~修改配置文件就可以的
姜小白- 2014-06-10
  • 打赏
  • 举报
回复
楼主先别结贴,再坚持几天。 应该有更好的办法的,像我们平时访问百度时,www.baidu.com 和 WWW.BAIDU.COM 都一样可以得到结果。 看看哪天有大牛路过时给一些好的提议,解决方案。
  • 打赏
  • 举报
回复
如果区分大小写 你可以通过 <Context path="/test" reloadable="true" docBase="\tomcat\webapp" workDir="/\work" /> 指定同一个目录
gzc145 2014-06-10
  • 打赏
  • 举报
回复
目前只能用傻办法来解决了在server.xml配置两个context,缺点是启应用的时候会启两个,哪位大神有更好的办法呢??? <Context path="/test" reloadable="true" docBase="D:\java\wzrkWorkspace\TEST\src\main\webapp" workDir="D:\java\wzrkWorkspace\TEST\work" /> <Context path="/TEST" reloadable="true" docBase="D:\java\wzrkWorkspace\TEST\src\main\webapp" workDir="D:\java\wzrkWorkspace\TEST\work" />
0ldPine 2014-06-09
  • 打赏
  • 举报
回复
3楼正解。。。
Mime_mi 2014-06-09
  • 打赏
  • 举报
回复
标记,学习下。
不是说好的吗 2014-06-09
  • 打赏
  • 举报
回复
tomcat重新部署下!!!
gzc145 2014-06-09
  • 打赏
  • 举报
回复
我在server.xml中的context是这样配置的 <Context path="/test" caseSensitive="false" reloadable="true" docBase="D:\java\wzrkWorkspace\TEST\src\main\webapp" workDir="D:\java\wzrkWorkspace\TEST" /> 用 http://localhost:8080/TEST/还是报的404
姜小白- 2014-06-09
  • 打赏
  • 举报
回复
不懂这个 mark 标记学习
不是说好的吗 2014-06-09
  • 打赏
  • 举报
回复
默认是不区分大小写的
不是说好的吗 2014-06-09
  • 打赏
  • 举报
回复
都可以,不区分大小写
jk1022 2014-06-09
  • 打赏
  • 举报
回复
正好不了解.MARK下
itzgs 2014-06-09
  • 打赏
  • 举报
回复
小写可以访问吗?
tony4geek 2014-06-09
  • 打赏
  • 举报
回复
来看看学习, url 重写是可以实现的 。
加载更多回复(1)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧