发表于: 2017-10-04 20:29:20
1 870
今天完成的事情:
一、任务四深度思考:
1.什么是jsp?
JSP的全称为Java Server Pages,翻译过来就是Java服务器页面,是一种可以在html中插入java代码和tag标签的动态网页技术,并且它是跨平台的
2.jsp有几个内置对象?
有九个内置对象,先说作用域:
Page:只在当前页有效,切换页面即失效
Request:可以跨越页面,但是只要请求释放,即失效
session:当前会话有效,只要用户不关闭浏览器,那么session是一直有效的
application:存活时间最长,只要不删除、不关闭web容器,就一直存活
Page域:response 、pageContext、out、config、page、exception
session域:session
Request域:request
Application域:application
最常用的对象:
request对象:客户端的请求信息,应用于传输信息到服务器
response对象:对客户端的响应,将JSP处理过的对象返回客户端,这个没用过,不是很清楚
session对象:为服务器自动创建的与用户相关的对象,用以储存用户的信息,跟踪用户的状态
3.熟练使用c标签,el表达式。
4.为什么要使用tiles框架?
用以达到页面复用,减少工作量,不过好像前段也有复用的手段,具体的还要等到以后才能知道
二、学习了Interceptor的相关知识
拦截设置:
在servlet文件中加入
<!--拦截器-->
<mvc:interceptors>
<mvc:interceptor>
<!-- 拦截所有URL中包含/u/的请求 -->
<mvc:mapping path="/u/**"/>
<bean class="cn.summerwaves.interceptor.LoginInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
这个配置表示的是拦截/u/xxx网址,并调用LoginInterceptor类进行拦截
实现拦截器的三个方法:
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
return false;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
preHandle :该方法将在请求处理之前进行调用
postHandle:preHandle 方法的返回值为true 时才能被调用,在Controller调用后执行,可以对controller处理的ModelAndView进行更改渲染
afterCompletion:同样preHandle 方法的返回值为true 时才能被调用,一般用于对资源的释放
示例没写出来
明天计划的事情:
使用拦截器拦截登录请求,学习cookie内容
遇到的问题:
对request和session不太熟悉,花了点时间去学习
收获:
1.学习了jsp的内置对象request和session的内容和用法
2.学习了拦截器的配置和方法的生命周期
3.一键实现接口方法
ALT+INSERT——>implement Methods
或 Ctrl + I
进度:
任务5开始时间:2017.10.03
预计demo时间:2017.10.08
延期风险:有
理由:依据学习的速度,以及是否遇到棘手问题
http://task.ptteng.com/zentao/project-task-350.html
评论