发表于: 2017-06-09 10:22:12

1 1271


今日完成

把t10css页面整出来了了。今天记录下数据库设计和tiles配置。

设计数据库表格

pom.xml添加依赖

<dependencies>
<!-- 添加Spring依赖 -->
   <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

<!--单元测试依赖 -->
   <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- 日志文件管理包 -->
   <!-- log start -->
   <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- log end -->

   <!--spring单元测试依赖 -->
   <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>

<!--mybatis依赖 -->
   <dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>

<!-- mybatis/spring包 -->
   <dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>

<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>

<!-- mysql驱动包 -->
   <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>

<!--sevlet web相关-->
   <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>runtime</scope>
</dependency>
<!-- 这里和tomcat中的jar包冲突,不用加这个 -->
   <!--<dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>javax.servlet-api</artifactId>
       <version>3.1.0</version>
   </dependency>-->
   <dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.0</version>
</dependency>

<!--spring tiles-->
   <!-- 这个集成了很多jar包,有些用不到,用下面分别添加的方法 -->
   <!--<dependency>
       <groupId>org.apache.tiles</groupId>
       <artifactId>tiles-extras</artifactId>
       <version>3.0.7</version>
   </dependency>-->
   <dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils-core</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>3.0.7</version>
</dependency>
</dependencies>

完成实体类 service serviceimpl model dao controller

controller

package com.oeasy.controller;

import com.oeasy.model.Student;
import com.oeasy.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
* Created by oeasy9999 on 2017/2/7.
*/
@Controller
@RequestMapping
public class TaskController {

@Autowired
   private StudentService studentService;

@RequestMapping(value = "/index.html", method = RequestMethod.GET)
public String index(Model model) {
List<Student> studentList = studentService.select();
model.addAttribute("studentList", studentList);
return "index";
}

@RequestMapping(value = "/occupation.html", method = RequestMethod.GET)
public String occupation(Model model) {
return "occupation";
}
}

index为首页t10

occupation为职业t11

 webapp文件夹下新建images js css文件夹,存放资源

layout文件夹下新建footer header template 三个jsp文件

footer header和html文件一致,template套用模板

index.jsp和occupation.jsp为替换的body

tiles.xml

<tiles-definitions>
<definition name="base.definition" template="/WEB-INF/layout/template.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/layout/header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/layout/footer.jsp" />
</definition>

<definition name="index" extends="base.definition">
<put-attribute name="title" value="首页"/>
<put-attribute name="body" value="/WEB-INF/views/index.jsp"/>
</definition>
<definition name="occupation" extends="base.definition">
<put-attribute name="title" value="职业"/>
<put-attribute name="body" value="/WEB-INF/views/occupation.jsp"/>
</definition>
</tiles-definitions>

出来就是这样

收获

css t10静态资源动态实现

困难

明日计划

css t11静态资源动态实现


返回列表 返回列表
评论

    分享到