我想在servlet中弹出一个窗口,如何写?

要那种小窗口... 要那种小窗口 展开
 我来答
dna53988
推荐于2016-02-17 · TA获得超过1.8万个赞
知道大有可为答主
回答量:8082
采纳率:22%
帮助的人:7934万
展开全部
看这段这是调用javabean的<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:useBean id="Purview" scope="page" class="com.teach.Main.PurviewBean" />
<%String userloginname = session.getAttribute("UserLoginName")
.toString();
String usertype = session.getAttribute("UserType").toString();
Collection plist = Purview.getPurviewList(userloginname, usertype);
if (plist == null) {
plist = new ArrayList();
}
pageContext.setAttribute("purviewlist", plist);
%>

这是拿个bean
package com.teach.Main;
import com.teach.db.ContextWy;
import com.teach.db.DBCPool;
import java.util.Collection;
import java.util.ArrayList;
import java.sql.*;

//得到左侧权限列表框
public class PurviewBean {
private String strDbip;
private String strType;
private String strUserid;
private Collection purviewlist;
private String strSQL;
private String strTemplate;
private String strQx;
public PurviewBean(){
strDbip=ContextWy.DEFAULT_DBIP;
strType="4";
strUserid="";
purviewlist=new ArrayList();
strSQL="";
strTemplate="";
strQx="";
}
public Collection getPurviewList(String userid,String usertype){
if(userid!=null&&(!userid.equals(""))){
strUserid=userid;
}
if(usertype!=null&&(!usertype.equals(""))){
strType=usertype;
}

DBCPool dbc= new DBCPool();
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
if(strType.equals("2")){
conn=dbc.getConnection("YuanDa",strDbip);
}else{
conn=dbc.getConnection("YuanDa",strDbip);
}
}catch(Exception e){
System.out.println("Conn Err :"+e.getMessage());
}
if(strType.equals("1")){
strSQL="select user_templateId as qx from users where user_name='"+strUserid+"'";
}else if(strType.equals("2")){
strSQL="select templateId as qx from student where name='"+strUserid+"'";
}
if(conn!=null){
try{
stmt=conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
}catch(Exception e1){
System.out.println("Stmt Err : "+e1.getMessage());
}
}
try{
//stmt=conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery(strSQL);
if(rs.next()){
strTemplate=rs.getString("qx");
}
rs.close();
if(!strTemplate.equals(""))
{
strSQL="select * from permission_templet where templet_id='"+strTemplate+"'";
}
rs=stmt.executeQuery(strSQL);
if(rs.next())
{
strQx=rs.getString("templet_permission");
}
if(!strQx.equals("")){
String[] strArr=strQx.split(",");
for(int i=0;i<strArr.length;i++){
Purview purview=new Purview();
strSQL="select * from Permission where permission_id='"+strArr[i]+"'";
rs=stmt.executeQuery(strSQL);
if(rs.next()){
purview.setQxid(Integer.toString(rs.getInt("permission_id")));
purview.setQxmc(rs.getString("permission_name"));
purview.setQxurl(rs.getString("permission_url"));
purview.setQxtarget(rs.getString("permission_target"));
purview.setQxfid(Integer.toString(rs.getInt("permission_parentId")));
String qxsign=rs.getString("permission_sign");
qxsign=qxsign.trim();
purview.setQxsign(qxsign);
}
rs.close();
purviewlist.add(purview);
}
}
stmt.close();
conn.close();
}catch(Exception er){
System.out.println("RS Err2 : "+er.getMessage());
}
return purviewlist;
}
}
注意路径,这就是javabean的用法
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式