string html = PrintTable(printvalue);Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", @"PrintView('" + html + "');", true);<script language="javascript" type="text/javascript">var LODOP; //声明为全局变量function PrintView(htmlHead) {LODOP = getLodop();LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_表单一");LODOP.SET_PRINT_STYLE("FontSize", 18);LODOP.SET_PRINT_STYLE("Bold", 1);LODOP.ADD_PRINT_HTM(40, 18, "97%", 200, htmlHead);LODOP.PREVIEW();};</script> 这样写不对。老是报错,谁能教我一下
2 回答
繁花如伊
TA贡献2012条经验 获得超12个赞
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
Compilable compilable = (Compilable) engine;
Bindings bindings = engine.createBindings(); // Local级别的Binding
String script = "var c; function add(op1,op2){ c=1; return c+op1+op2} add(a, b)"; // // 定义函数并调用
CompiledScript JSFunction = compilable.compile(script); // 解析编译脚本函数
bindings.put("a", 1);
bindings.put("b", 2);
// 通过Bindings加入参数
Object result = JSFunction.eval(bindings);
System.out.println(result); // 调用缓存着的脚本函数对象,Bindings作为参数容器传入
out.print(result);
- 2 回答
- 0 关注
- 651 浏览
添加回答
举报
0/150
提交
取消