0904
1)Lock锁的使用
原文链接:https://blog.youkuaiyun.com/weixin_34214500/article/details/87950521
2)静态include原理
被包含的jsp文件本身不会被单独翻译成一个Servlet文件,而是把它们翻译成Servlet拼接到index_jsp.java这个Servlet文件中,所以我们在apache/work目录下只能看到index_jsp.java这一个Servlet文件。
3)maven的servlet,jsp,jstl的标准配置
<!-- Servlet -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<scope>provided</scope>
<version>9.0.24</version>
</dependency>
<!-- JSP -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<scope>provided</scope>
<version>9.0.24</version>
</dependency>
<!--jstl-->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jstl-impl</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
</exclusion>
</exclusions>
</dependency>
4). 和 [ ] 有什么区别 ?
答案:. 和 [ ] 都可以用来取得EL 属性值,.可以实现的功能[ ] 也都可以!
例如: ${pageScope.user.name} 也可以写为 ${pageScope.user[“name”]}
[ ] 可以使用特殊标识信息,但是. 不可以
例如:
pageContext.setAttribute(“0”,“itcast”);
pageContext.setAttribute(“aa.bb”,“春生泰克”);
只能通过 [ ] 进行访问 ----- 注意:在使用[ ] 进行属性取值时,要加"" , 若不加"" 则认为是一个变量
结论:在使用EL进行取值时,如果含有特使字符属性,尽量使用[ ] , 否则都使用 . 就可以了!
5)EL 11个内置对象
[外链图片转存失败(img-MQKi7dH3-1567719704851)(C:\Users\15566\AppData\Roaming\Typora\typora-user-images\1567628934406.png)]
ageScope、requestScope、sessionScope、applicationScope 四个数据范围,用来取值
pageContext 当前jsp上下文 ----- ${pageContext.request.contextPath }
${param.name} 等价于 request.getParameter(“name”)
${paramValues.hobby} 等价于 request.getParameterValues(“hobby”)
${header.referer} 等价于 request.getHeader(“referer”)
${headerValues[“Accept-Encoding”]} 等价于 request.getHeaders(“Accept-Encoding”)
${initParam.name} 等价于 getServletContext().getInitParamter(“name”)
6)request.getContextPath()
https://www.cnblogs.com/yuan1225/p/3219629.html
//单元格渲染器
class MyCellRenderer extends JLabel implements ListCellRenderer{
public MyCellRenderer() {
this.setOpaque(true);
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
if(value!=null){
setText(value.toString());
ImageIcon img=new ImageIcon("images//touxiang.jpg");
img.setImage(img.getImage().getScaledInstance(50,50,Image.SCALE_DEFAULT));
setIcon(img);
}
if(isSelected){
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}else{
setBackground(list.getBackground());
setForeground(list.getForeground());
}
return this;
}
}