今天实训复习了一下eclipse基本结构,下面简单总结一下:
1、项目目录(Dynamic Web Project)
/test/src java代码/包
/test/WebContent 项目发布根目录 (公开目录)
/test/WebContent/META-INF 签名文件(安全目录)
/test/WebContent/WEB-INF (配置文件)安全目录)
/test/WebContent/WEB-INF/lib 扩展jar包
2、url
http://localhost/test/index.jsp?name=123&sex=1
协议://主机:端口/项目目录/请求路径?参数=值&参数1=值
localhost:127.0.0.1
3、servlet 类
请求接收/业务处理/结果回应
4、请求/回应
4.1 地址重定向 (get)
(修改地址栏回车,< a > ,location.href,open())
4.2 form标签 (get,post)
4.3 ajax异步请求(get,post)
4.3.1 拼接回应数据(html) ABA
resp.getWriter().write(“hahahah < a href=’#’> hello world </ a>ah”);
4.3.2 请求重定向(mvc模式 数据进入视图通过引擎渲染,回应结果页面信息)ABBA
req.getRequestDispatcher(“index.jsp”).include(req, resp);
4.3.3 地址重定向(回应通知浏览器的地址栏修改) ABABA
resp.sendRedirect(“index.jsp”);
4.3.4 回应数据本身(将数据转换为json字符串),jackson框架,必须使用ajax请求
resp.getWriter().write("{“sex”:1}");
5、jstl 后端标签库
<c:out> 用于在JSP中显示数据,就像<%= … >
<c:set> 用于保存数据
<c:remove> 用于删除数据
……
更多可参考菜鸟教程:https://www.runoob.com/jsp/jsp-jstl.html
6、EL表达式
Servlet中:@WebServlet("/Aaa")
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("sexs",new String[] {"男性","女性"});
//request变量,请求内有效
request.getRequestDispatcher("a.jsp").forward(request,response);
}
a.jsp中:
<body>
${sexs[0]}
<!--
显示:“男性”
从page/request值域中获取变量值
运行后把网址输入网页,把JSP名(a)换成Servlet名(Aaa)
-->
<!-- 变量定义时不用EL表达式,变量获取时才用 -->
</body>
7、服务器域变量
page 当前页有效
request 当前请求有效
session 当前会话有效
application 当前启动有效
8、MVC 开发模式,并行开发
MODEL 业务模板 自身业务实现(业务细节)
VIEW 视图 (数据渲染展示,无业务逻辑)
CONTROLLER 控制器 (请求,回应,业务指派)
9、spring (容器)
反射: user u =new user();
Class CLS=Class.forname(“user”);
object u=CLS.newinstance();
ioc 注入依赖
aop 面向切面开发,代理模式
10、spring mvc (替代servlet)
项目启动时,将controller加入容器(记录地址映射集合)
11、mybatis orm框架(对象关系映射)
将查询结果集自动转为对象集合
12、maven 构建框架
官方仓库,私服仓库,本地仓库
pom.xml