简体   繁体   English

我在 JSP 中写了一个相对路径,但它不起作用

[英]I wrote a relative path in JSP but it's not working

I created a webservice project named FirstTest using dwr.我使用 dwr 创建了一个名为 FirstTest 的 web 服务项目。

In WebContent folder I have a JSP.在 WebContent 文件夹中,我有一个 JSP。 After successful deployment there is a JS部署成功后有一个JS

localhost:8080/FirstTest/dwr/interface/getdata.js本地主机:8080/FirstTest/dwr/interface/getdata.js

So in JSP I wrote所以在 JSP 我写了

<script type="text/javascript" src="/FirstTest/dwr/interface/getdata.js">

Now I rename the project to SecondTest then the js location changed to现在我将项目重命名为 SecondTest 然后 js 位置更改为

localhost:8080/SecondTest/dwr/interface/getdata.js本地主机:8080/SecondTest/dwr/interface/getdata.js

and I have to rewrite the JSP file path.我必须重写 JSP 文件路径。 Then how to use relative path instead?那么如何使用相对路径呢? I tried我试过了

<script type="text/javascript" src="../dwr/interface/getdata.js">

and

<script type="text/javascript" src="/dwr/interface/getdata.js">

but both not working.但两者都不起作用。

Thx for any help.感谢您的帮助。

<script type="text/javascript" src="/dwr/interface/getdata.js">

In this line the first "/" means the the root directory of your site.在这一行中,第一个“/”表示您网站的根目录。 Check the deployed root directory in your server and make sure from root directory this file path is present.检查服务器中部署的根目录,并确保根目录中存在此文件路径。 Rest looks good on this line. Rest 在这条线上看起来不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM