1

我正在Tomcat下使用jsp(实际上是gsp)运行应用程序。所有 URL 都是绝对的。也就是说,每个 href 都以“/”开头。例如:

<a href="/mytool/role/index" class="menulink">Role</a>

每个请求都会收到一个名为 SYS.WEBSYSTEM_PREFIX 的参数,该参数必须添加到每个 URL 之前。

也就是说,如果请求是

http://myDomain/mytool/xxx?SYS.WEBSYSTEM_PREFIX=some_path

那么上面的 URL 必须重写为:

    some_path/mytool/index

我认为这可以使用 HTML 标签在全球范围内完成。

我的意图如下:

<base href=<% request.getParameter("SYS.WEBSYSTEM_PREFIX"); %> />

但它没有用。

因此问题是:

  • 有可能以这种方式应对这个问题吗?
  • 如果是。这个怎么做?

提前致谢。

路易斯

4

2 回答 2

1

当您的 <a href=""> 以 / 开头时,HTML <base href=""/> 不起作用。

于 2009-09-22T17:44:20.117 回答
0

it would be a better idea to write a jsp custom tag that you will use instead of the a tag, which will append that path to the begining of your paths.

some think like this:

<custom:a href="/some/path" text="blah"/>

you may need to add some other attributes like onclick etc as well.

于 2009-09-22T17:53:51.457 回答