我试图通过从JSP中的请求参数,在我的基于struts的项目中将字符串值传递给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%>‘)//单个报价之间