我试图在基于Struts的项目中通过从JSP中的request参数获取字符串值到JavaScript函数。这是代码:
<% String timeVal = "Not found"; if(request.getAttribute("myDate")!=null){ timeVal= (String)request.getAttribute("myDate"); } %>
然后将其作为参数传递给函数
<html:submit property = "save" styleClass = "button_c" onclick = "return SubmitPage('update', <%=timeVal %>)">Save</html:submit>
JavaScript函数在哪里
function SubmitPage(action, aa) { alert("Date is ...." + aa); }
但是当我尝试运行它给我一个错误
HTTP Status 400 - Request[/AMResourceLibraryListAction] does not contain handler parameter named ref
在网页上显示消息。
Request[/AMResourceLibraryListAction] does not contain handler parameter named ref
提前致谢。
编辑 这里是堆栈跟踪
[ERROR] DispatchAction - -Request[/AMResourceLibraryListAction] does not contain handler parameter named ref
这对我有用:
<html:submit property = "save" styleClass = "button_c" onclick = "return SubmitPage('<%=timeVal %>')">Save</html:submit>
(’<%= timeVal%>’)//两次引用之间