创建了Income.java,Expense.java,DataDict.java,Security.java,first.java,StockHolding.java实体类以及控制器,jsp和对应的show

main
Asus 4 months ago
parent 916f449975
commit b7d22827c4

@ -0,0 +1,17 @@
// DataDictController.java
package com.ssm.controller;
import com.ssm.entity.DataDict;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class DataDictController {
@RequestMapping("/submitDataDict")
public String handleDataDict(DataDict dataDict) {
System.out.println("新增字典项: "
+ "键=" + dataDict.getKey()
+ ", 值=" + dataDict.getValue()
+ ", 类型=" + dataDict.getType());
return "showDataDict";
}
}

@ -0,0 +1,17 @@
// ExpenseController.java
package com.ssm.controller;
import com.ssm.entity.Expense;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class ExpenseController {
@RequestMapping("/submitExpense")
public String handleExpense(Expense expense) {
System.out.println("收到支出信息: "
+ "金额=" + expense.getAmount()
+ ", 类别=" + expense.getCategory()
+ ", 备注=" + expense.getRemarks());
return "showExpense";
}
}

@ -0,0 +1,17 @@
// SecurityAccountController.java
package com.ssm.controller;
import com.ssm.entity.SecurityAccount;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class SecurityAccountController {
@RequestMapping("/submitSecurityAccount")
public String handleSecurityAccount(SecurityAccount account) {
System.out.println("创建证券账户: "
+ "账户ID=" + account.getAccountId()
+ ", 持有人=" + account.getOwnerName()
+ ", 券商=" + account.getBroker());
return "showSecurityAccount";
}
}

@ -0,0 +1,17 @@
// StockHoldingController.java
package com.ssm.controller;
import com.ssm.entity.StockHolding;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class StockHoldingController {
@RequestMapping("/submitStockHolding")
public String handleStockHolding(StockHolding stock) {
System.out.println("记录持股信息: "
+ "股票代码=" + stock.getSymbol()
+ ", 数量=" + stock.getQuantity()
+ ", 买入价=" + stock.getPurchasePrice());
return "showStockHolding";
}
}

@ -0,0 +1,39 @@
package com.ssm.entity;
public class DataDict {
private Integer dictId;
private String key;
private String value;
private String type;
public Integer getDictId() {
return dictId;
}
public void setDictId(Integer dictId) {
this.dictId = dictId;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

@ -0,0 +1,49 @@
package com.ssm.entity;
import java.util.Date;
public class Expense {
private Integer id;
private Double amount;
private Date date;
private String category;
private String remarks;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
}

@ -1,93 +1,49 @@
package com.ssm.entity; package com.ssm.entity;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
public class Income { public class Income {
private Integer id; // 编号 private Integer id;
private User user; // 收入用户 private Double amount;
private Datadic incometype; // 收入类型 private Date date;
private String source; // 来源 private String category;
private Integer money; // 金额 private String description;
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() { public Integer getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
public String getSource() {
return source; public Double getAmount() {
} return amount;
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 setAmount(Double amount) {
this.amount = amount;
} }
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime; public Date getDate() {
return date;
} }
public User getUser() { public void setDate(Date date) {
return user; this.date = date;
} }
public void setUser(User user) { public String getCategory() {
this.user = user; return category;
} }
public Datadic getIncometype() { public void setCategory(String category) {
return incometype; this.category = category;
} }
public void setIncometype(Datadic incometype) { public String getDescription() {
this.incometype = incometype; return description;
} }
@Override public void setDescription(String description) {
public String toString() { this.description = description;
return "Income{" +
"id=" + id +
// 输出收入用户名
", username='" + user.getUsername() + '\'' +
// 输出收入类型
", incometype=" + incometype.getDatadicvalue() +
", source=" + source +
", money='" + money + '\'' +
", incometime='" + incometime + '\'' +
'}';
} }
} }

@ -0,0 +1,39 @@
package com.ssm.entity;
public class SecurityAccount {
private String accountId;
private String ownerName;
private Double balance;
private String broker;
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public Double getBalance() {
return balance;
}
public void setBalance(Double balance) {
this.balance = balance;
}
public String getBroker() {
return broker;
}
public void setBroker(String broker) {
this.broker = broker;
}
}

@ -0,0 +1,39 @@
package com.ssm.entity;
public class StockHolding {
private String stockId;
private String symbol;
private Integer quantity;
private Double purchasePrice;
public String getStockId() {
return stockId;
}
public void setStockId(String stockId) {
this.stockId = stockId;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public Double getPurchasePrice() {
return purchasePrice;
}
public void setPurchasePrice(Double purchasePrice) {
this.purchasePrice = purchasePrice;
}
}

@ -1,12 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context"
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"> xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.ssm.controller"></context:component-scan> <!-- 启用注解驱动 -->
<mvc:annotation-driven/>
<!-- 静态资源处理 -->
<mvc:resources mapping="/static/**" location="com"/>
<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"></property> <property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"></property> <property name="suffix" value=".jsp"/>
</bean> </bean>
<!-- 扫描Controller -->
<context:component-scan base-package="com.ssm.controller"/>
</beans> </beans>

@ -0,0 +1,7 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<body>
<h1>Success! 字典项已保存!</h1>
继续添加
</body>
</html>

@ -1,16 +0,0 @@
<%@ 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,7 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<body>
<h1>Success! 支出信息已成功记录!</h1>
继续添加
</body>
</html>

@ -1,15 +1,7 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" <%@ page 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> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>展示Controller接收及响应数据</title>
</head>
<body> <body>
Success! <h1>Success! 收入信息已成功记录!</h1>
<br> 继续添加
收入信息已在控制台输出!
</body>
</body> </body>
</html> </html>

@ -0,0 +1,7 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<body>
<h1>Success! 证券账户已创建!</h1>
继续添加
</body>
</html>

@ -0,0 +1,7 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<body>
<h1>Success! 持股信息已记录!</h1>
继续添加
</body>
</html>

@ -1,10 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"> version="4.0">
<!-- 字符编码过滤器 -->
<filter>
<filter-name>encodingFilter</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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring上下文加载 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:java</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring MVC DispatcherServlet -->
<servlet> <servlet>
<servlet-name>DispatcherServlet</servlet-name> <servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param> <init-param>
<param-name>contextConfigLocation</param-name> <param-name>contextConfigLocation</param-name>
@ -13,8 +43,7 @@
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name> <servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern> <url-pattern>/</url-pattern>
</servlet-mapping> </servlet-mapping>
</web-app> </web-app>

@ -0,0 +1,20 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>添加数据字典</title>
</head>
<body>
<h2>新增字典项</h2>
<form action="submitDataDict" method="post">
键名: <input type="text" name="key" required><br>
键值: <input type="text" name="value" required><br>
类型:
<select name="type">
<option value="category">分类</option>
<option value="status">状态</option>
<option value="config">配置</option>
</select><br>
<input type="submit" value="提交">
</form>
</body>
</html>

@ -0,0 +1,21 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>添加支出记录</title>
</head>
<body>
<h2>新增支出</h2>
<form action="submitExpense" method="post">
金额: <input type="number" step="0.01" name="amount" required><br>
日期: <input type="date" name="date" required><br>
类别:
<select name="category">
<option value="餐饮">餐饮</option>
<option value="交通">交通</option>
<option value="住房">住房</option>
</select><br>
备注: <textarea name="remarks" rows="3"></textarea><br>
<input type="submit" value="提交">
</form>
</body>
</html>

@ -1,57 +1,21 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" <%@ page 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> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加收入记录</title>
<title>添加收入信息</title>
</head> </head>
<body> <body>
<form action="income/add" method="post"> <h2>新增收入</h2>
<table> <form action="submitIncome" method="post">
<tr> 金额: <input type="number" step="0.01" name="amount" required><br>
<td>收入编号:</td> 日期: <input type="date" name="date" required><br>
<td width="20"></td> 类别:
<td><input type="text" name="id" placeholder="请输入收入编号" /></td> <select name="category">
</tr> <option value="工资">工资</option>
<tr> <option value="投资">投资</option>
<td>收入用户:</td> <option value="其他">其他</option>
<td width="20"></td> </select><br>
<td><input type="text" name="user.username" placeholder="请输入收入用户" /></td> 描述: <textarea name="description" rows="3"></textarea><br>
</tr> <input type="submit" value="提交">
<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> </form>
</body> </body>
</html> </html>

@ -0,0 +1,16 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>添加证券账户</title>
</head>
<body>
<h2>新增证券账户</h2>
<form action="submitSecurityAccount" method="post">
账户ID: <input type="text" name="accountId" required><br>
持有人: <input type="text" name="ownerName" required><br>
初始资金: <input type="number" step="0.01" name="balance" required><br>
券商名称: <input type="text" name="broker" required><br>
<input type="submit" value="提交">
</form>
</body>
</html>

@ -0,0 +1,16 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>添加持股记录</title>
</head>
<body>
<h2>新增持股</h2>
<form action="submitStockHolding" method="post">
股票代码: <input type="text" name="symbol" required><br>
数量: <input type="number" name="quantity" min="1" required><br>
买入价格: <input type="number" step="0.01" name="purchasePrice" required><br>
账户ID: <input type="text" name="stockId" required><br>
<input type="submit" value="提交">
</form>
</body>
</html>
Loading…
Cancel
Save