发表于: 2018-10-14 20:36:07

1 481


今天完成的事情:

1.完成t11页面的拆分,与t10公共部分人复用。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html>
   <html>
   <head>
   <tiles:insertAttribute name="meta"/>
<title><tiles:insertAttribute name="t11"/></title>
   <tiles:insertAttribute name="script"/>
</head>
   <body>
   <div id="header">
   <tiles:insertAttribute name="header"/>
</div>
   <div id="one_11">
   <tiles:insertAttribute name="one_11"/>
</div>
   <div id="jobShow1">
   <tiles:insertAttribute name="jobShow1"/>
</div>
   <div id="jobShow2">
   <tiles:insertAttribute name="jobShow2"/>
</div>
   <div id="footer1">
   <tiles:insertAttribute name="footer1"/>
</div>
   <div id="footer">
   <tiles:insertAttribute name="footer"/>
</div>
   </body>
   </html>


配置tiles框架配置文件

<definition name="tiles.index.definition2" extends="tiles.base.definition" template="/WEB-INF/view/layout/second_layout.jsp">
   <put-attribute name="one_11" value="/WEB-INF/view/snippet/secondBody/one_11.jsp"/>
   <put-attribute name="jobShow1" value="/WEB-INF/view/snippet/secondBody/jobShow1.jsp"/>
   <put-attribute name="jobShow2" value="/WEB-INF/view/snippet/secondBody/jobShow2.jsp"/>
</definition>

测试:


2)时间格式的转换

自定义一个taglib的标签处理时间转换。

创建一个类继承TagSupport

package task4.util;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DateTag extends TagSupport {
private static final long serialVersionUID = 6464168398214506236L;
   private String value;

   @Override
   public int doStartTag() throws JspException {
String vv = "" + value;
       try {
long time = Long.valueOf(vv.trim());
           Calendar c = Calendar.getInstance();
           c.setTimeInMillis(time);
           SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
           String s = dateformat.format(c.getTime());
           pageContext.getOut().write(s);
       } catch (Exception e) {
e.printStackTrace();
       }
return super.doStartTag();
   }

public void setValue(String value) {
this.value = value;
   }
}

创建一个.tld文件加入如下内容

<?xml version="1.0" encoding= "UTF-8"?>
<taglib>
   <tlib-version>1.0</tlib-version>
   <jsp-version>1.2</jsp-version>

   <short-name>date</short-name>

   <tag>
       <name>date</name>
       <tag-class>task4.util.DateTag</tag-class>
       <body-content>JSP</body-content>
       <attribute>
           <name>value</name>
           <required>true</required>
           <rtexprvalue>true</rtexprvalue>
       </attribute>
   </tag>
</taglib>

在web文件里面关联这个标签

<jsp-config>
 <taglib>
   <taglib-uri>/tags</taglib-uri>
   <taglib-location>/WEB-INF/tld/datetag.tld</taglib-location>
 </taglib>
</jsp-config>

测试在jsp中用

3)部署到云服务器,由于maven配置问题,暂时不能把一些jar包打入到本地仓库(我的maven有毒),估计部署项目要花个一天解决问题。



明天计划做的事:两边持续进行,一遍学习部署知识,一遍进行任务五的准备阶段。





返回列表 返回列表
评论

    分享到