如何从servlet调用JavaScript的功能 [英] How to call function of JavaScript from servlet

查看:147
本文介绍了如何从servlet调用JavaScript的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是网络开发的新手。我有一个外部JavaScript文件,它有一个函数显示
提示错误详细信息。我需要将错误消息传递给该函数。我在servlet中编写了控制器。

I am new to web development. I have an external JavaScript file which has a function to show a prompt with error details. I need to pass the error message to the function. I have written contoller in servlet.

如何从我的servlet调用该JavaScript文件的函数。

How to call the function of that JavaScript file from my servlet.

推荐答案

无法从servlet调用java脚本函数。相反,你可以使用

It is not possible to call a java script function from a servlet. Rather, you can print javascript code using

response.getOutputStream()。println([javascript code]);

进入浏览器,然后javascript函数将在浏览器中执行。

into the browser and then the javascript function will be executed in the browser.

这篇关于如何从servlet调用JavaScript的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆