像普通打印一样通过jsp打印页面

时间:2012-02-22 11:53:25

标签: javascript html jsp printing

好吧最后我需要在这里问我的问题,因为我找不到任何解决方案。我的问题是,当我点击打印按钮(在该页面上)时,如何打印jsp页面?例如,我有一个jsp页面,我写了一些东西然后当我点击打印按钮(如提交按钮)然后jsp页面将被发送打印,当我将点击打印在该打印屏幕上然后页面将被打印。有什么帮助吗?

<html>
<head>
<title>A jsp page</title>
</head>
<body>

//have written something and want to print this by java code

<input type="submit" value="print"/>// click here to print
</body>
</html>

2 个答案:

答案 0 :(得分:4)

<input type="submit" value="print" onClick="window.print()"/> 

答案 1 :(得分:0)

请试试这个:

<p class="print-align-right">
     <a href="#" onclick="javascript:window.print();" >Print this page</a>
</p>
相关问题