我是想在JAVA类里编写HTML代码,能行吗?我是想在运行错误是弹出一个警示框!能行吗?
追答可以啊,你要真的学会的话,建议你去学习下javascript基本语法,半天就够了。不然在这边问的话学不到什么
追问File ff=con.DateDerived(request);
if(ff==null){
out.println("alert('没有上传文件,请上传文件!'); window.location='index.jsp' ");
}
就是想弹出这个?怎么实现啊?
out.println用的很少 ,我试下。
追问能行了嘛?
本回答被网友采纳我是想在JAVA类里编写HTML代码,能行吗?我是想在运行错误是弹出一个警示框!能行吗?
追答你可以参照这个:http://zhidao.baidu.com/question/43734419.html
追问File ff=con.DateDerived(request);
if(ff==null){
out.println("alert('没有上传文件,请上传文件!'); window.location='index.jsp' ");
}
就是想弹出这个?怎么实现啊?
---------------------------------------------------
File ff=con.DateDerived(request);
if(ff==null){
out.println("alert('没有上传文件,请上传文件!'); window.location='index.jsp' ");
}
---------------------------------------------------
以上代码中,把
out.println("alert('没有上传文件,请上传文件!'); window.location='index.jsp' ");
改为:
strAlert="alert('没有上传文件,请上传文件!'); window.location='index.jsp' ")
把strAlert定义为Public String 默认值为空字符串,然后,在jsp中用
但是strAlert在我这里报错啊?是怎么回事,大侠
追答在类开始时,添加 public String strAlert="";
例子:
解决了没?我做了个例子:
Tclass.java 代码(我把Tclass.java 建在名为TP的包中):
package TP;
public class Tclass {
public String aa="alert(1)";
}
test.jsp 代码:
Insert title here
直接运行jsp就行
File ff=con.DateDerived(request);
if(ff==null){
out.println("alert('没有上传文件,请上传文件!'); window.location='index.jsp' ");
}
就是想弹出这个?怎么实现啊?