简体   繁体   中英

when I try to concatenate a string within a JSTL tag. An error occur

str += "<td><fmt:formatDate value='"+notices[i].noticeDuration+"' type='date' dateStyle='default' pattern='yyyy-MM-dd HH:mm' /></td>";

I am trying to concatenate a string, and append it to the body. Due to the JSTL tag---fmt, an error occurs. It said I lost a quotation. I tried to figure out why it happened, with no luck.

Like this, JSP compiler will see notices[i].noticeDuration as string as is, not date value. Because notices[i].noticeDuration run client (browser). So, you can't use JS variable in JSTL tags.

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