想要将Java值传递到jsp中的javascript函数中 [英] Want to pass the java value into javascript function in jsp
本文介绍了想要将Java值传递到jsp中的javascript函数中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在基于Struts的项目中,我试图通过从JSP中的request参数获取字符串值到JavaScript函数.这是代码:
I am trying to pass a string value to a JavaScript function by taking from request parameter in JSP, in my struts based project. here is the code:
<%
String timeVal = "Not found";
if(request.getAttribute("myDate")!=null){
timeVal= (String)request.getAttribute("myDate");
}
%>
然后将其作为参数传递给函数
and then pass it in function as parameter
<html:submit property = "save" styleClass = "button_c" onclick = "return SubmitPage('update', <%=timeVal %>)">Save</html:submit>
其中的JavaScript函数是
Where the JavaScript function is
function SubmitPage(action, aa)
{
alert("Date is ...." + aa);
}
但是当我尝试运行它时,它给了我一个错误
But when i try to run this it gives me an error
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%>')//单个报价之间
('<%=timeVal %>') // between single Quotation
这篇关于想要将Java值传递到jsp中的javascript函数中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文