本文介绍了如何显示从数据库到Java脚本变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Java Servlet代码,从中我从数据库表中获得3个字段,并且我想在JS(Java脚本)页面上以html标签(例如Name =)显示此字段,并且我想从datbase中显示名字字段标签名称的前面.

i have created one java servlet code from which i get 3 field from database table and i want to show this field on my js(java script) page in html tag like Name= and i want to show first name field from datbase infront of lable Name.

推荐答案


<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <h1>Welcome to Javascript - Database Interactioin</h1>
    <hr />
    <script type="text/javascript">
        var x = document.cookie;
        alert(x);
    </script>
    <a href="GetData.do">Get Data</a>
</body>
</html>






数据库: MyDB
表:员工
列: EmpID,名称,地址,电话,电子邮件






Database:MyDB
Table:Employee
Columns: EmpID, Name, Address, Phone, Email


这篇关于如何显示从数据库到Java脚本变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 09:28