我需要在 Struts2 下的页面中嵌入图像按钮。
不幸的是,无法使用绝对路径,因此我需要与应用程序相关的网址,但 不起作用,并且预期的网址: app/i/go_btn.gif
未解析。另一方面 无法使用,因为错误:“src 不接受任何表达式”
所以问题:如何以应用程序相对格式在 s:submit 标记中指定图像的 url?
I need embed image button to page under Struts2.
Unfortunately absolute path cannot be used, so I need application-related url, but <s:submit type="image" src="i/go_btn.gif"
doesn't work and expected url: app/i/go_btn.gif
is not resolved. On other hand <s:url
cannot be used because of error: "src does not accept any expressions"
So question: how to specify url of image in s:submit tag in application relative format?
发布评论
评论(2)
也许使用根相对路径。
在 url 前面放置“/”表示应用程序的根目录。请参阅http://www.coderanch.com/how-to/java/RelativeLinks
use a root relative path perhaps.
placing "/" before the url means the root of the app. See http://www.coderanch.com/how-to/java/RelativeLinks
我找到了自己的解决方案。提交控件的模板 (submit.ftl) 似乎包含以下 src 属性行:
这就是为什么
的代码始终生成为指定的网址。必须更改如下:
I've found my own solution. It is appeared that template for submit control (submit.ftl) contains following line for src attribute:
That is why code for
<input type="image"
always generated with specified URL. It have to be changed as follow: