java jsp html_jsp中 java ,html/javascript 交互

一、说明几点:(1)过程描述:

Jsp文件首先在服务器端生成中间的Java文件,再生成Class,然后以html的形式返回到客户端。

所以说,一个jsp文件首先执行其中的java代码,然后生成html。

(2)类型

a.java类型(就不描述了)

b.javascript 的类型

string, number, Boolean,Undefined and Null,

object, Array, Date, Math 等

javascript 是一种Dynamic Typing,Every JavaScript variable has a data type,

but the type is inferred from the variable’s content.

//var favNumber;

//favNumber = 3;

//favNumber = "San Diego";

//First, when the variable favNumber is declared, it is empty. In fact,

//its data type is actually the type undefined. Then we assign it to the number 3,

//so its data type is 3. Next we reassign it to the string "San Diego",

//so the variable’s type is now string. As you can see, types are inferred from content,

//and a variable automatically takes on the type of the data it contains.

二、交互

1 java --> html

直接使用表达式

//

2  java  --> javascript

由于两种类型的不同,如果java的值能够转化成数字。

String i ="1.02";

Integer i = new Integer(22);

float i = 10;

都可以直接和javascript的类型交互,即直接传给javascript变量

//

// 也可以

如果java的值不能够转化成数字

String s ="1.jsp";

需要转化为javascript的字符串类型

//

//

//

3. html --> java

%>

html code....

%>

4. javascript --> java// //

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值