您的位置:首页 > 移动开发

jsp的application使用案例

2015-09-14 23:05 267 查看
【web.xml页面】

<servlet>

    <description>This is the description of my J2EE component</description>

    <display-name>This is the display name of my J2EE component</display-name>

    <servlet-name>InitSer</servlet-name>

    <servlet-class>servlet.InitSer</servlet-class>

    <load-on-startup>0</load-on-startup>

  </servlet>

【servlet部分】

public void init() throws ServletException {
// Put your code here
ArrayList<Grade> grades=gradeimpl.queryGrade("");
ServletContext app=this.getServletContext();//得到application的一个容器--属于tomcat
app.setAttribute("grades",grades);
String[] slikes={"唱歌","跳舞","篮球","乒乓","足球"};
app.setAttribute("slikes", slikes);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jsp servlet application