一、bootstrap
本项目采用bootstrap3
使用bootstrap三步:
1.导入jQuery
2.导入bootstrap自己的css样式
3.导入bootstrap自己的js文件
bootstrap定义了大量的样式库,要使用样式,只要将元素的class指定为样式库中的值。
二、第一个网页
index.jsp
和css等资源文件一起放在web层的webapp下
新建plugin文件夹,bootstrap放在里面
此时启动项目,发现样式不对
F12控制台报错
资源路径进行配置
样式在网页推荐写绝对路径
写监听器
web层创建
编写监听器
packagecom.atguigu.scw.manager.listener;importjavax.servlet.ServletContext;importjavax.servlet.ServletContextEvent;importjavax.servlet.ServletContextListener;/*** 项目启动时,将一些常用数据放在application域中,大家都能用
* @ClassName MyAppListener
* @Description TODO(这里用一句话描述这个类的作用)*@version1.0.0*/
public class MyAppListener implementsServletContextListener{public voidcontextInitialized(ServletContextEvent sce) {
ServletContext servletContext=sce.getServletContext();//1.将项目放在application域中
servletContext.setAttribute("ctp", servletContext.getContextPath());
}public voidcontextDestroyed(ServletContextEvent sce) {//2.项目关闭,销毁application域中所有数据
}
}
在web.xml中进行配置
com.atguigu.scw.manager.listener.MyAppListener
contextConfigLocation
classpath:spring-*.xml
org.springframework.web.context.ContextLoaderListener
springDispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:springmvc.xml
1
springDispatcherServlet
/
CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
utf-8
forceRequestEncoding
true
forceResponseEncoding
true
CharacterEncodingFilter
/*
index.jsp中资源的路径都如下面所示,将路径和实际资源位置一一检查
css
js
重新运行
网页显示正常