我有以下代码:
<html:submit onclick="saveuc(<%=request.getAttribute("userId") %>,<%=request.getAttribute("domainName")%>,<%=request.getAttribute("applicationName")%>,<%=request.getAttribute("domainId")%>)">Save</html:submit>
任何人都可以帮助解决这里的语法错误吗?
我得到以下异常
Servlet.service() for servlet action threw exception: javax.servlet.jsp.JspException: ServletException in '/common-layout.jsp': ServletException in 'pages/UseCaseScreen.jsp': /pages/UseCaseScreen.jsp(62,82) equal symbol expected
答案 0 :(得分:0)
解决该问题的最简单方法可能是使用EL(表达式语言)。所以只需用
替换现有代码即可<html:submit onclick="saveuc(${userId},${domainName},${applicationName},${domainId})">Save</html:submit>
EL(至少在这种情况下)使用隐式对象(requestScope),因此您也可以编写
<html:submit onclick="saveuc(${requestScope.userId},${requestScope.domainName},${requestScope.applicationName},${requestScope.domainId})">Save</html:submit>