如何在 JavaScript 函数中使用 Strut 标签?

How to use Strut tags inside JavaScript functions?

我正在尝试在 JavaScript 函数中检索带有 struts 标记的值,因为它被调用了很多次,我不会在需要时对每一行进行相应的更改。我想做一次。

我在同一个地方工作 JSP:

function myNewWindow(file_type, file_name){
    Window= window.open('MyClassAction_ac.do?metodo=Start&docType='+file_type+'&docName='+file_name,'_blank','width=810,menubar=no,toolbar=no,scrollable=yes,resizable=no');
}

.....

<a href="javascript:myNewWindow('<bean:write name="MyClass" property="type"/>','<bean:write name="MyClass" property="name"/>');">
    <img src="<%=path%>img/img1.jpg" width="14" height="14" hspace="0">
</a>

但我需要这样的东西:

function myNewWindow(){
   var file_Type= <%= <bean:write name="MyClass" property="type"/> %>
   var file_name = <%= <bean:write name="MyClass" property="name"/> %>
   Window= window.open('MyClassAction_ac.do?metodo=Start&docType='+file_type+'&docName='+file_name,'_blank','width=810,menubar=no,toolbar=no,scrollable=yes,resizable=no');
}

它应该有效:

var file_Type= '<bean:write name="instanceofMyClass" property="type"/>'

因此您需要在以下范围之一中拥有 myclass 的实例:请求、会话或应用程序