有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在jsp中使用美元登录

我使用Spring MVC&;jsp

是我的家庭控制器。返回“测试字符串”

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

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

return "home"; }

回家。jsp

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

如何使用美元登录<;%%>


共 (2) 个答案

  1. # 1 楼答案

    脚本中不允许使用el表达式,您应该可以直接使用el

  2. # 2 楼答案

    您应该使用Scriptlet或jstl
    这样做可能更好:

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