发表于: 2020-05-30 21:24:51
1 1476
今天完成的事情:
学习HTML标签:
<a>:定义超链接,从一张页面链接到另外一张页面。
<b> :规定粗体文本。
<basefont>:定义基准字体。该标签可以为文档中的所有文本定义默认字体颜色、字体大小和字体系列
<big> 标签呈现大号字体效果。
<body> 定义文档的主体。包含文档的所有内容(比如文本、超链接、图像、表格和列表等等。)
<br> 可插入一个简单的换行符。
<button> 标签定义一个按钮。
<canvas> 标签定义图形,比如图表和其他图像。
caption 元素定义表格标题。
caption 标签必须紧随 table 标签之后。您只能对每个表格定义一个标题。通常这个标题会被居中于表格之上。
<table> 标签定义 HTML 表格。
继续整合SSM:
Controller层:
package com.jnshu.Controller;
import com.jnshu.Model.Student;
import com.jnshu.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 java.util.List;
@Controller
@RequestMapping("/Student")
public class StudentController {
@Autowired
StudentService studentService;
@RequestMapping("/SelectById")
public String SelectById(Long ID,Model model){
model.addAttribute("student",studentService.SelectById(ID));
return "SelectById";
}
@RequestMapping("/GetAllStudent")
public String GetAllStudent(Model model){
List<Student> students = studentService.GetAllStudent();
model.addAttribute("studentList",students);
return "GetAllStudent";
}
@RequestMapping("/Insert")
public String Insert(Student student){
studentService.Insert(student);
return "Insert";
}
@RequestMapping("/Delete")
public String Delete(Long ID){
studentService.Delete(ID);
return "Delete";
}
@RequestMapping("/Update")
public String Update(Student student){
studentService.Update(student);
return "Update";
}}
编写index.jsp:
<h3>根据ID查询学员</h3>
<form action="/Student/SelectById" method="post">
ID:<input type="text" name="ID"/><br>
<input type="submit" value="提交"/>
</form>
运行结果:
<a href="/Student/GetAllStudent">查询所有学生</a>
<h3>删除学员</h3>
<form action="/Student/Delete" method="post">
ID:<input type="text" name="ID"/><br>
<input type="submit" value="提交"/>
</form>
<h3>添加学员</h3>
<form action="/Student/Insert" method="post">
ID:<input type="text" name="ID"/><br>
姓名:<input type="text" name="Name"/><br>
QQ:<input type="text" name="QQ"/><br>
学习类型:<input type="text" name="Type"/><br>
入学时间:<input type="text" name="Time"/><br>
毕业院校:<input type="text" name="School"/><br>
学号:<input type="text" name="Num"/><br>
日报链接:<input type="text" name="Link"/><br>
立愿:<input type="text" name="Wish"/><br>
师兄:<input type="text" name="Leader"/><br>
创建时间:<input type="text" name="Create_at"/><br>
更新时间:<input type="text" name="Update_at"/><br>
<input type="submit" value="添加"/>
</form><br>
<h3>修改学员信息</h3>
<form action="/Student/Update" method="post">
ID:<input type="text" name="ID"/><br>
姓名:<input type="text" name="Name"/><br>
QQ:<input type="text" name="QQ"/><br>
学习类型:<input type="text" name="Type"/><br>
入学时间:<input type="text" name="Time"/><br>
毕业院校:<input type="text" name="School"/><br>
学号:<input type="text" name="Num"/><br>
日报链接:<input type="text" name="Link"/><br>
立愿:<input type="text" name="Wish"/><br>
师兄:<input type="text" name="Leader"/><br>
创建时间:<input type="text" name="Create_at"/><br>
更新时间:<input type="text" name="Update_at"/><br>
<input type="submit" value="修改"/>
</form><br>
使用SSM进行增删改查成功。
使用Spring Rest 编写对应的Controller。
什么是restful?
RESTful架构,就是目前最流行的一种互联网软件架构。它结构清晰、符合标准、易于理解、扩展方便,所以正得到越来越多网站的采用。
rest(Representational State Transfer),即表现层状态转化。它省略了主语,"表现层"其实指的是"资源"(Resources)的"表现层"。
所谓"资源",就是网络上的一个实体,或者说是网络上的一个具体信息。它可以是一段文本、一张图片、一首歌曲、一种服务,总之就是一个具体的实在。你可以用一个URI(统一资源定位符)指向它,每种资源对应一个特定的URI。要获取这个资源,访问它的URI就可以,因此URI就成了每一个资源的地址或独一无二的识别符。
所谓"上网",就是与互联网上一系列的"资源"互动,调用它的URI。
访问一个网站,就代表了客户端和服务器的一个互动过程。在这个过程中,势必涉及到数据和状态的变化。
互联网通信协议HTTP协议,是一个无状态协议。这意味着,所有的状态都保存在服务器端。因此,如果客户端想要操作服务器,必须通过某种手段,让服务器端发生"状态转化"(State Transfer)。而这种转化是建立在表现层之上的,所以就是"表现层状态转化"。
客户端用到的手段,只能是HTTP协议。具体来说,就是HTTP协议里面,四个表示操作方式的动词:GET、POST、PUT、DELETE。它们分别对应四种基本操作:GET用来获取资源,POST用来新建资源(也可以用于更新资源),PUT用来更新资源,DELETE用来删除资源。
综合上面的解释,我们总结一下什么是RESTful架构:
(1)每一个URI代表一种资源;
(2)客户端和服务器之间,传递这种资源的某种表现层;
(3)客户端通过四个HTTP动词,对服务器端资源进行操作,实现"表现层状态转化"。
今天完成的事情:初步整合了SSM框架,简单学习了HTML标签,了解了restful风格。
明天计划完成的事情:使用Spring Rest 编写对应的Controller。要开始做任务二的具体任务了。
碰到的问题:有关rest还是有些迷糊。
评论