日常小記

0904

1)Lock鎖的使用

原文鏈接:https://blog.csdn.net/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;
	}	
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章