简体   繁体   中英

How to print a gsp from controller using a printer?

I need to pass some values to a template and then print the template. How can I achieve that? Thanks in advance.

As I understand, you want to automatically start printing of rendered gsp page. You shouldn't try to do this from the controller, the controller is used for passing parameters to .gsp page which is rendered as HTML.

You can automatically start printer by putting this javascript in your gsp file:

<script>

$(document).ready(function(){
    window.print();
});

</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM