简体   繁体   中英

Struts tag in Javascript call

I have a JSP page where I want to say something like:

<... onclick="alert('<bean:message key="msg.oops" />')" ... />

This does not work. The page is not rendered. It works fine if I have just:

<... onclick="f('Oops!')" ... />

How should this be done?

Use bean:define to copy the message, then use a JSP expression.

<bean:define id="oops"><bean:message key="msg.oops"></bean:define>
<... onclick="alert('<%= oops %>') ... />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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