在JAVA类中弹出JS对话框
3个回答
展开全部
1:java程序
package org.elb.util;
public class JavaScriptDemo_1 {
public static String getJS(){
return "<script language=\"JavaScript\">alert(\"弹出框\")</script>";
}
}
2:JSP页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<jsp:useBean id="a" class="org.elb.util.JavaScriptDemo_1"></jsp:useBean>
<%=a.getJS() %>
</body>
</html>
想弹出什么来,就写什么就行了,明白了吗?
package org.elb.util;
public class JavaScriptDemo_1 {
public static String getJS(){
return "<script language=\"JavaScript\">alert(\"弹出框\")</script>";
}
}
2:JSP页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<jsp:useBean id="a" class="org.elb.util.JavaScriptDemo_1"></jsp:useBean>
<%=a.getJS() %>
</body>
</html>
想弹出什么来,就写什么就行了,明白了吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询