初始项目

main
bainan 2 months ago
parent a3ec73bbf4
commit f77114803b

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

@ -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,18 @@
package com.ssm.controller;
import com.ssm.entity.Income;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("income")
public class IncomeController {
//对象方式接收收入信息
@RequestMapping("add")
public String test(Income income){
System.out.println("收入信息:"+income.toString());
return "showIncome";
}
}

@ -0,0 +1,26 @@
package com.ssm.entity;
public class Datadic {
private Integer id; // 编号
private String datadicname; // 数据字典名称
private String datadicvalue; // 数据字典值
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDatadicname() {
return datadicname;
}
public void setDatadicname(String datadicname) {
this.datadicname = datadicname;
}
public String getDatadicvalue() {
return datadicvalue;
}
public void setDatadicvalue(String datadicvalue) {
this.datadicvalue = datadicvalue;
}
}

@ -0,0 +1,93 @@
package com.ssm.entity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
public class Income {
private Integer id; // 编号
private User user; // 收入用户
private Datadic incometype; // 收入类型
private String source; // 来源
private Integer money; // 金额
private String content; // 备注
@DateTimeFormat(pattern = "yyyy-mm-dd HH:mm:ss")
private Date incometime; // 收入时间
@DateTimeFormat(pattern = "yyyy-mm-dd HH:mm:ss")
private Date createtime; // 创建时间
@DateTimeFormat(pattern = "yyyy-mm-dd HH:mm:ss")
private Date updatetime; // 更新时间
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public Integer getMoney() {
return money;
}
public void setMoney(Integer money) {
this.money = money;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getIncometime() {
return incometime;
}
public void setIncometime(Date incometime) {
this.incometime = incometime;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Datadic getIncometype() {
return incometype;
}
public void setIncometype(Datadic incometype) {
this.incometype = incometype;
}
@Override
public String toString() {
return "Income{" +
"id=" + id +
// 输出收入用户名
", username='" + user.getUsername() + '\'' +
// 输出收入类型
", incometype=" + incometype.getDatadicvalue() +
", source=" + source +
", money='" + money + '\'' +
", incometime='" + incometime + '\'' +
'}';
}
}

@ -0,0 +1,113 @@
package com.ssm.entity;
/**
*
*/
public class User {
private Integer id; // 编号
private String username; // 用户名
private String password; // 密码
private String truename; // 真实姓名
private String email; // 邮件
private String phone; // 电话
private String address; // 住址
private Integer sex; // 性别
private Integer age; // 年龄
private String appellation; // 家庭称谓
private Integer salary; // 薪水工资
private String card; // 银行卡号
private Integer isvalid; // 是否有效
private String createtime; // 创建时间
private String updatetime; // 修改时间
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTruename() {
return truename;
}
public void setTruename(String truename) {
this.truename = truename;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Integer getSex() {
return sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getAppellation() {
return appellation;
}
public void setAppellation(String appellation) {
this.appellation = appellation;
}
public Integer getSalary() {
return salary;
}
public void setSalary(Integer salary) {
this.salary = salary;
}
public String getCard() {
return card;
}
public void setCard(String card) {
this.card = card;
}
public Integer getIsvalid() {
return isvalid;
}
public void setIsvalid(Integer isvalid) {
this.isvalid = isvalid;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getUpdatetime() {
return updatetime;
}
public void setUpdatetime(String updatetime) {
this.updatetime = updatetime;
}
}

@ -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,16 @@
<%@ 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>
收入类型编号:${datadicInfo.id}
<br>
收入类型名称:${datadicInfo.datadicvalue}
</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,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,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,19 @@
<%@ 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="datadic/add" method="post">
收入类型编号:<input type="text" name="id">
<br>
收入类型名称:<input type="text" name="datadicvalue">
<br>
<input type="submit" value="添加">
</form>
</body>
</html>

@ -0,0 +1,57 @@
<%@ 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="income/add" method="post">
<table>
<tr>
<td>收入编号:</td>
<td width="20"></td>
<td><input type="text" name="id" placeholder="请输入收入编号" /></td>
</tr>
<tr>
<td>收入用户:</td>
<td width="20"></td>
<td><input type="text" name="user.username" placeholder="请输入收入用户" /></td>
</tr>
<tr>
<td>收入类型:</td>
<td width="20"></td>
<td><input type="text" name="incometype.datadicvalue" placeholder="请输入收入类型" /></td>
</tr>
<tr>
<td>来源:</td>
<td width="20"></td>
<td><input type="text" name="source" placeholder="请输入来源" /></td>
</tr>
<tr>
<td>金额:</td>
<td width="20"></td>
<td><input type="text" name="money" value="" class="bg" placeholder="金额" /></td>
</tr>
<tr>
<td>收入时间:</td>
<td width="20"></td>
<td><input type="text" name="incometime" placeholder="请输入收入时间" /></td>
</tr>
<tr>
<td>备注:</td>
<td width="20"></td>
<td><textarea name="content" rows="5" cols="35"></textarea></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,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