简体   繁体   中英

How to use dollar sign in jsp

I use Spring MVC & jsp.

It's my homeController. return "test String";

@RequestMapping(value="/",method = RequestMethod.GET)
public String home(Locale locale,Model model){

model.addAttribute("test","test String");

return "home"; }

home.jsp

<html><head>
<% String test = ${test} %>
</head>
<body>
${test} //it shows "test String"
<%=test%>  //but it doesn't show anything. error. 
</body></html>

how to use dollar sign in <% %> ?

在script-let中不允许使用el表达式,您应该只能使用EL

You should use either scriptlets or jstl.
It could be better to do like this:

<html>
<body>
<c:out value="${test}"/>
</body>
</html>

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