初始项目

main
bainan 5 months ago
parent fc21d6b579
commit c8fc88b242

@ -0,0 +1,18 @@
package com.ssm.controller;
import com.ssm.entity.Equip;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("equipment")
public class EquipController {
//对象方式接收设备信息
@RequestMapping("add")
public String test(Equip equipment){
System.out.println("设备信息:"+equipment.toString());
return "showEquipment";
}
}

@ -0,0 +1,13 @@
package com.ssm.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class FirstController {
@RequestMapping("hello")
public String hello() {
System.out.println("1111");
return "showFirst";
}
}

@ -0,0 +1,22 @@
package com.ssm.controller;
import com.ssm.entity.Labx;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("laboratory")
public class LabxController {
//对象方式接收数据ModelAndView对象响应数据
@RequestMapping("add")
public ModelAndView test(Labx laboratory){
//创建ModelAndView对象的同时设置了view的信息
ModelAndView mv=new ModelAndView("showLaboratory");
//将这个对象laboratory保存到ModelAndView对象中
mv.addObject("laboratoryInfo", laboratory);
return mv;
}
}

@ -0,0 +1,46 @@
package com.ssm.entity;
// 设备类型表的实体类
public class Cate {
private String cateid; // 设备类型id
private String catename; // 类型名称
private String addtime; // 创建日期
private String memo; // 备注
public String getCateid() {
return cateid;
}
public void setCateid(String cateid) {
this.cateid = cateid;
}
public String getCatename() {
return catename;
}
public void setCatename(String catename) {
this.catename = catename;
}
public String getAddtime() {
return addtime;
}
public void setAddtime(String addtime) {
this.addtime = addtime;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public void printMessage(){
System.out.println("this is Category");
}
}

@ -0,0 +1,128 @@
package com.ssm.entity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
// 设备表的实体类
public class Equip {
private String equipid; // 设备id
private String eno; // 设备号
private String equipname; // 设备名称
private String useinfo; // 设备作用
private String productor; // 生产厂商
private String price; // 采购金额
@DateTimeFormat(pattern = "yyyy-mm-dd")
private Date buydate; // 采购日期
private String manager; // 负责人
private String memo; // 备注
private Cate cate;// 多对一映射类
private Labx labx;// 多对一映射类
public String getEquipid() {
return equipid;
}
public void setEquipid(String equipid) {
this.equipid = equipid;
}
public String getEno() {
return eno;
}
public void setEno(String eno) {
this.eno = eno;
}
public String getEquipname() {
return equipname;
}
public void setEquipname(String equipname) {
this.equipname = equipname;
}
public String getUseinfo() {
return useinfo;
}
public void setUseinfo(String useinfo) {
this.useinfo = useinfo;
}
public String getProductor() {
return productor;
}
public void setProductor(String productor) {
this.productor = productor;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public Date getBuydate() {
return buydate;
}
public void setBuydate(Date buydate) {
this.buydate = buydate;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public Cate getCate() {
return cate;
}
public void setCate(Cate cate) {
this.cate = cate;
}
public Labx getLabx() {
return labx;
}
public void setLabx(Labx labx) {
this.labx = labx;
}
@Override
public String toString() {
return "Equipment{" +
"equipid=" + equipid +
", equipname='" + equipname + '\'' +
", eno=" + eno +
", productor=" + productor +
", price='" + price + '\'' +
", buydate='" + buydate + '\'' +
", manager=" + manager +
", useinfo=" + useinfo +
// 输出设备分类名称
", categoryName=" + cate.getCatename() +
// 输出设备所在实验室名称
", categoryName=" + labx.getLabxname() +
'}';
}
}

@ -0,0 +1,83 @@
package com.ssm.entity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
// 实验室表的实体类
public class Labx {
private String labxid; // 实验室id
private String labxname; // 实验室名称
private String manager; // 负责人
private String contact; // 联系方式
private String address; // 实验室地址
@DateTimeFormat(pattern = "yyyy-mm-dd")
private Date addtime; // 创建日期
private String memo; // 备注
public String getLabxid() {
return labxid;
}
public void setLabxid(String labxid) {
this.labxid = labxid;
}
public String getLabxname() {
return labxname;
}
public void setLabxname(String labxname) {
this.labxname = labxname;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getAddtime() {
return addtime;
}
public void setAddtime(Date addtime) {
this.addtime = addtime;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public void printMessage(){
System.out.println("this is Laboratory");
}
}

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 配置注解扫描器配置spring容器初始化对象时需要扫描的包 -->
<context:component-scan base-package="com.ssm.controller"></context:component-scan>
<!-- 配置视图解析器,ctrl+shift+t搜索类将return的字符串逻辑视图+前缀+后缀,转换成真正的物理视图 -->
<!-- 逻辑视图success,真正的视图:/WEB-INF/view/success.jsp -->
<!-- -->
<!-- 配置注解驱动 -->
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/view/"></property>
<!-- 后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
</bean>
</beans>

Binary file not shown.

Binary file not shown.

@ -0,0 +1,15 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示Controller接收及响应数据</title>
</head>
<body>
Success!
<br>
设备信息已在控制台输出!
</body>
</body>
</html>

@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示入门程序信息</title>
</head>
<body>
Success!
</body>
</html>

@ -0,0 +1,22 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示实验室信息</title>
</head>
<body>
Success!
<br>
实验室编号:${laboratoryInfo.labxid}
<br>
实验室名称:${laboratoryInfo.labxname}
<br>
负责人:${laboratoryInfo.manager}
<br>
联系方式:${laboratoryInfo.contact}
<br>
地址:${laboratoryInfo.address}
</body>
</html>

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SpringMVCFirst</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置DispatcherServlet的初始化参数 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- 配置SpringMVC配置文件的位置和名称-->
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<!-- 该servlet在第一次加载的时候就被创建而不是等请求时才创建 -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<!-- 可以应答所有请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--编码过滤器,解决中文乱码问题-->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

@ -0,0 +1,67 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加设备</title>
</head>
<body>
<form action="equipment/add" method="post">
<table>
<tr>
<td>设备号:</td>
<td width="20"></td>
<td><input type="text" name="eno" placeholder="请输入设备号" /></td>
</tr>
<tr>
<td>设备名称:</td>
<td width="20"></td>
<td><input type="text" name="equipname" placeholder="请输入设备名称" /></td>
</tr>
<tr>
<td>设备分类:</td>
<td width="20"></td>
<td><input type="text" name="cate.catename" placeholder="请输入设备分类" /></td>
</tr>
<tr>
<td>所属实验室:</td>
<td width="20"></td>
<td><input type="text" name="labx.labxname" placeholder="请输入所属实验室" /></td>
</tr>
<tr>
<td>设备作用:</td>
<td width="20"></td>
<td><input type="text" name="useinfo" placeholder="请输入设备作用" /></td>
</tr>
<tr>
<td>生产厂商:</td>
<td width="20"></td>
<td><input type="text" name="productor" placeholder="请输入生产厂商" /></td>
</tr>
<tr>
<td>采购金额:</td>
<td width="20"></td>
<td><input type="text" name="price" class="bg" placeholder="请输入采购金额" /></td>
</tr>
<tr>
<td>采购日期:</td>
<td width="20"></td>
<td><input type="text" name="buydate" placeholder="请输入采购日期" /></td>
</tr>
<tr>
<td>负责人:</td>
<td width="20"></td>
<td><input type="text" name="manager" placeholder="请输入负责人" /></td>
</tr>
<tr>
<td align="right"><input type="reset" value="重置"></td>
<td></td>
<td align="center">
<input type="submit" value="添加">
</td>
</tr>
</table>
</form>
</body>
</html>

@ -0,0 +1,25 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加实验室信息</title>
</head>
<body>
<form action="laboratory/add" method="post">
实验室编号:<input type="text" name="labxid">
<br>
实验室名称:<input type="text" name="labxname">
<br>
负责人:<input type="text" name="manager">
<br>
联系方式:<input type="text" name="contact">
<br>
地址:<input type="text" name="address">
<br>
<input type="submit" value="添加">
</form>
</body>
</html>

@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>入门程序</title>
</head>
<body>
<a href="hello">hello world</a>
</body>
</html>
Loading…
Cancel
Save