Redian新闻
>
请问JSP里这个<a href=???>怎么设
avatar
请问JSP里这个<a href=???>怎么设# Java - 爪哇娇娃
w*y
1
【 以下文字转载自 Programming 讨论区 】
【 原文由 woomy 所发表 】
我现在用jsp做网页, 用tomcat 做jsp server
我知道硬盘上一个txt文件的绝对路径, 譬如path=/home/woomy/text.txt
我想做个link可以指向这个文件,用户click这个link可以打开这个文件,
可是我试了一下link 不行
我把鼠标放在link上的时候状态栏显示的是
http://hostname:port/home/woomy/test.txt
我知道tomcat是到他的webapps/root下面找文件, 请问这个href该怎么设呢?
多谢多谢!
?
avatar
x*n
2
Your local files are secured, unless you
explicitly share them, either by copying the files
under the directory that was set as Tomcat's web root,
or create some virtual directory under that root.
Don't know if a softlink works or not.

【在 w***y 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 【 原文由 woomy 所发表 】
: 我现在用jsp做网页, 用tomcat 做jsp server
: 我知道硬盘上一个txt文件的绝对路径, 譬如path=/home/woomy/text.txt
: 我想做个link可以指向这个文件,用户click这个link可以打开这个文件,
: 可是我试了一下link 不行
: 我把鼠标放在link上的时候状态栏显示的是
: http://hostname:port/home/woomy/test.txt
: 我知道tomcat是到他的webapps/root下面找文件, 请问这个href该怎么设呢?
: 多谢多谢!

avatar
c*g
3
if it is under unix/linux, you can set a link (using ln) to text.txt
from doc root of your web application.
If it is under windows, set a shortcut, but I am not sure if this
works.
another solution, you create a jsp, which reads text.txt and displays
it.

【在 w***y 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 【 原文由 woomy 所发表 】
: 我现在用jsp做网页, 用tomcat 做jsp server
: 我知道硬盘上一个txt文件的绝对路径, 譬如path=/home/woomy/text.txt
: 我想做个link可以指向这个文件,用户click这个link可以打开这个文件,
: 可是我试了一下link 不行
: 我把鼠标放在link上的时候状态栏显示的是
: http://hostname:port/home/woomy/test.txt
: 我知道tomcat是到他的webapps/root下面找文件, 请问这个href该怎么设呢?
: 多谢多谢!

avatar
w*y
4

thx a lot! But it has to be a hard link, I tried ln -s first, failed:(

【在 c**g 的大作中提到】
: if it is under unix/linux, you can set a link (using ln) to text.txt
: from doc root of your web application.
: If it is under windows, set a shortcut, but I am not sure if this
: works.
: another solution, you create a jsp, which reads text.txt and displays
: it.

avatar
B*N
5
It's browser interpret "/" as your application root. not jsp in this case.
the browser always get other files relative to this page or relative to the
tag if it exists. If browser find the url init with "/" it will always
go to web application root to find the path.
now you should know how to set.

【在 w***y 的大作中提到】
:
: thx a lot! But it has to be a hard link, I tried ln -s first, failed:(

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。