jsp java函数,在jsp文件中创建java函数并从另一个jsp文件中调用它

本文介绍了在JSP环境下,如何在不接触Java文件的情况下,通过嵌入代码而非包括页面的方式,实现A.jsp调用B.jsp中的函数。重点讲解了使用<%=%>嵌入代码与直接指令嵌入代码的区别,以确保正确获取到函数功能。
摘要由CSDN通过智能技术生成

We generally create methods in a java class, import them into a jsp file and call those methods in our jsp files.

But we are working in a client environment, we do not have access to create or modify .java files. So we desperately need to create a function in a jsp file and call it from another jsp file.

For example:

A.jsp

.....

....

B.jsp ....

public String getName()

{

return "Hello";

}

>%

Is there any way to do this?.

解决方案

Yes you can, instead of

Use

Including page will just embed two jsp code so you are not getting that function but including file using directives will embed code first and then compile so you will get your function.

You can find difference here

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值