博主介绍:✌在职Java研发工程师、专注于程序设计、源码分享、技术交流、专注于Java技术领域和毕业设计

项目名称

java mysql物联网土壤智能监控web前端+java后台+数据接程序

视频效果

https://www.bilibili.com/video/BV12e4y1D78C/

系统说明

a.   嵌入式技术:嵌硬件层使用数据接收server端(UDP)。

b.  前端技术使用vue:vue是一套用于构建用户界面的渐进式JavaScript框架。与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用。Vue 的核心库只关注视图层,方便与第三方库或既有项目整合

c.  后台使用springmvc构建:Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。使用 Spring 可插入的 MVC 架构,从而在使用Spring进行WEB开发时,可以选择使用Spring的Spring MVC框架或集成其他MVC开发框架,如Struts1(现在一般不用),Struts 2(一般老项目使用)等等。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
5.数据库:MySql 5.7版本;
6.是否Maven项目:否;

技术栈

1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录

运行截图

用户管理控制层:

package com.houserss.controller;import javax.servlet.http.HttpSession;import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import com.houserss.common.Const;
import com.houserss.common.Const.Role;
import com.houserss.common.ServerResponse;
import com.houserss.pojo.User;
import com.houserss.service.IUserService;
import com.houserss.service.impl.UserServiceImpl;
import com.houserss.util.MD5Util;
import com.houserss.util.TimeUtils;
import com.houserss.vo.DeleteHouseVo;
import com.houserss.vo.PageInfoVo;/*** Created by admin*/
@Controller
@RequestMapping("/user/")
public class UserController {@Autowiredprivate IUserService iUserService;/*** 用户登录* @param username* @param password* @param session* @return*/@RequestMapping(value = "login.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<User> login(User user,String uvcode, HttpSession session){String code = (String)session.getAttribute("validationCode");if(StringUtils.isNotBlank(code)) {if(!code.equalsIgnoreCase(uvcode)) {return ServerResponse.createByErrorMessage("验证码不正确");}}ServerResponse<User> response = iUserService.login(user.getUsername(),user.getPassword());if(response.isSuccess()){session.setAttribute(Const.CURRENT_USER,response.getData());}return response;}}

管理员管理控制层:


package com.sxl.controller.admin;import java.util.List;
import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import com.sxl.controller.MyController;@Controller("adminController")
@RequestMapping(value = "/admin")
public class AdminController extends MyController {@RequestMapping(value = "/index")public String frame(Model model, HttpServletRequest request)throws Exception {return "/admin/index";}@RequestMapping(value = "/main")public String main(Model model, HttpServletRequest request)throws Exception {return "/admin/main";}@RequestMapping(value = "/tj1")public String tj1(Model model, HttpServletRequest request)throws Exception {String sql="select DATE_FORMAT(insertDate,'%Y-%m-%d') dates,sum(allPrice) price from t_order order by DATE_FORMAT(insertDate,'%Y-%m-%d')  desc";List<Map> list = db.queryForList(sql);model.addAttribute("list", list);System.out.println(list);return "/admin/tj/tj1";}@RequestMapping(value = "/password")public String password(Model model, HttpServletRequest request)throws Exception {return "/admin/password";}@RequestMapping(value = "/changePassword")public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {Map admin = getAdmin(request);if(oldPassword.equals(admin.get("password").toString())){String sql="update t_admin set password=? where id=?";db.update(sql, new Object[]{newPassword,admin.get("id")});return renderData(true,"1",null);}else{return renderData(false,"1",null);}}
}

修改密码业务逻辑:


package com.sxl.controller.admin;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import com.sxl.controller.MyController;@Controller("userController")
@RequestMapping(value = "/user")
public class UserController extends MyController {@RequestMapping(value = "/index")public String frame(Model model, HttpServletRequest request)throws Exception {return "/user/index";}@RequestMapping(value = "/main")public String main(Model model, HttpServletRequest request)throws Exception {return "/user/main";}@RequestMapping(value = "/password")public String password(Model model, HttpServletRequest request)throws Exception {return "/user/password";}@RequestMapping(value = "/changePassword")public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {Map user = getUser(request);if(oldPassword.equals(user.get("password").toString())){String sql="update t_user set password=? where id=?";db.update(sql, new Object[]{newPassword,user.get("id")});return renderData(true,"1",null);}else{return renderData(false,"1",null);}}@RequestMapping(value = "/mine")public String mine(Model model, HttpServletRequest request)throws Exception {
Map user =getUser(request);Map map = db.queryForMap("select * from t_user where id=?",new Object[]{user.get("id")});model.addAttribute("map", map);        return "/user/mine";}@RequestMapping(value = "/mineSave")public ResponseEntity<String> mineSave(Model model,HttpServletRequest request,Long id,String username,String password,String name,String gh,String mobile) throws Exception{int result = 0;String sql="update t_user set name=?,gh=?,mobile=? where id=?";result = db.update(sql, new Object[]{name,gh,mobile,id});if(result==1){return renderData(true,"操作成功",null);}else{return renderData(false,"操作失败",null);}}}

通用管理模块:

package com.sxl.controller;import java.nio.charset.Charset;
import java.util.Locale;
import java.util.ResourceBundle;import javax.servlet.http.HttpServletRequest;import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;import com.sxl.util.JacksonJsonUtil;
import com.sxl.util.StringUtil;
import com.sxl.util.SystemProperties;public class BaseController {public static final Long EXPIRES_IN = 1000 * 3600 * 24 * 1L;// 1天@Autowiredprivate SystemProperties systemProperties;/*** 获得配置文件内容*/public String getConfig(String key) {return systemProperties.getProperties(key);}/*** 返回服务器地址 like http://192.168.1.1:8441/UUBean/*/public String getHostUrl(HttpServletRequest request) {String hostName = request.getServerName();Integer hostPort = request.getServerPort();String path = request.getContextPath();if (hostPort == 80) {return "http://" + hostName + path + "/";} else {return "http://" + hostName + ":" + hostPort + path + "/";}}/**** 获取当前的website路径 String*/public static String getWebSite(HttpServletRequest request) {String returnUrl = request.getScheme() + "://"+ request.getServerName();if (request.getServerPort() != 80) {returnUrl += ":" + request.getServerPort();}returnUrl += request.getContextPath();return returnUrl;}/*** 初始化HTTP头.* * @return HttpHeaders*/public HttpHeaders initHttpHeaders() {HttpHeaders headers = new HttpHeaders();MediaType mediaType = new MediaType("text", "html",Charset.forName("utf-8"));headers.setContentType(mediaType);return headers;}/*** 返回 信息数据* * @param status* @param msg* @return*/public ResponseEntity<String> renderMsg(Boolean status, String msg) {if (StringUtils.isEmpty(msg)) {msg = "";}String str = "{\"status\":\"" + status + "\",\"msg\":\"" + msg + "\"}";ResponseEntity<String> responseEntity = new ResponseEntity<String>(str,initHttpHeaders(), HttpStatus.OK);return responseEntity;}/*** 返回obj数据* * @param status* @param msg* @param obj* @return*/public ResponseEntity<String> renderData(Boolean status, String msg,Object obj) {if (StringUtils.isEmpty(msg)) {msg = "";}StringBuffer sb = new StringBuffer();sb.append("{");sb.append("\"status\":\"" + status + "\",\"msg\":\"" + msg + "\",");sb.append("\"data\":" + JacksonJsonUtil.toJson(obj) + "");sb.append("}");ResponseEntity<String> responseEntity = new ResponseEntity<String>(sb.toString(), initHttpHeaders(), HttpStatus.OK);return responseEntity;}/**** 获取IP(如果是多级代理,则得到的是一串IP值)*/public static String getIpAddr(HttpServletRequest request) {String ip = request.getHeader("x-forwarded-for");if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("Proxy-Client-IP");}if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("WL-Proxy-Client-IP");}if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getRemoteAddr();}if (ip != null && ip.length() > 0) {String[] ips = ip.split(",");for (int i = 0; i < ips.length; i++) {if (!"unknown".equalsIgnoreCase(ips[i])) {ip = ips[i];break;}}}return ip;}/*** 国际化获得语言内容* * @param key*            语言key* @param args* @param argsSplit* @param defaultMessage* @param locale* @return*/public static String getLanguage(String key, String args, String argsSplit,String defaultMessage, String locale) {String language = "zh";String contry = "cn";String returnValue = defaultMessage;if (!StringUtil.isEmpty(locale)) {try {String[] localeArray = locale.split("_");language = localeArray[0];contry = localeArray[1];} catch (Exception e) {}}try {ResourceBundle resource = ResourceBundle.getBundle("lang.resource",new Locale(language, contry));returnValue = resource.getString(key);if (!StringUtil.isEmpty(args)) {String[] argsArray = args.split(argsSplit);for (int i = 0; i < argsArray.length; i++) {returnValue = returnValue.replace("{" + i + "}",argsArray[i]);}}} catch (Exception e) {}return returnValue;}
}

源码获取:
大家点赞、收藏、关注、评论啦 、查看

java mysql物联网土壤智能监控web前端+java后台+数据接程序相关推荐

  1. web前端与后台数据交互

    1.前端请求数据URL由谁来写? 在开发中,URL主要是由后台来写的,写好了给前端开发者.如果后台在查询数据,需要借助查询条件才能查询到前端需要的数据时,这时后台会要求前端提供相关的查询参数,这里的查 ...

  2. 在web前端调用后台java程序(java类)的方式

    在web前端调用后台java程序(java类)的方式: 首先静态html标签是无法直接调用java程序的,但是可以通过imput button按钮点击,onclick事件调用一个js函数,用这个js函 ...

  3. 软件开发全套视频教程汇总(javaSE,javaEE,linux,android开发,C# ,web前端,大数据云计算,数据挖掘,web前端,php开发,UI设计,C++开发,3D视频)

    软件开发全套视频教程汇总(javaSE,javaEE,linux,android开发,C# ,web前端,大数据云计算,数据挖掘,web前端,php开发,UI设计,C++开发,3D视频) 这是我以前学 ...

  4. date javascript 时区_第23节 Datejs 日期库-Web前端开发之Javascript-零点程序员-王唯

    Datejs 是一个开源的JavaScript库,用来解析.格式化和处理日期数据,支持多种语言的日期格式处理:官网:www.datejs.com/ Moment.js 是一个简单易用的轻量级JavaS ...

  5. 【学习笔记】Web前端到后端数据的交互

    [学习笔记]Web前端到后端数据的交互

  6. 垃圾分类网站 web前端 + java后端

    数据库设计 垃圾分类知识表: 字段名称 数据类型 id(唯一标识) BIGINT(20) title(名称) VARCHAR(255) image(图片) VARCHAR(255) content(介 ...

  7. python web前端 java ui学哪个好_学IT选Java还是Python?就业发展有何区别?

    学IT选Java还是Python?就业发展有何区别? 来源:奇酷学院 发表于:2018-09-27 10:14:35 想了解一个语言就业到底好不好,得先明确语言的发展方向. 很多学员在选择专业上遇着难 ...

  8. web前端3.0时代,“程序猿”如何“渡劫升仙”?

    世界上目前已经有超过18亿的网站.其中只有不到2亿的网站是活跃的.且每天都有几千个新网站不断被创造出来. 2017年成果显著,网络上出现了像Vue这样的新JavaScript框架:基于用户体验流程的开 ...

  9. web 前端和后台配合工作流程

    下面结合代码演示前端和后台配合工作流程. GET方式 <!DOCTYPE html> <html> <head><meta http-equiv=" ...

最新文章

  1. caffe的python接口学习(6):用训练好的模型(caffemodel)来分类新的图片
  2. OpenVAS漏洞扫描基础教程之创建用户
  3. 引用 vsftpd配置手册(实用)
  4. XGBoost 重要参数、方法、函数理解及调参思路(附例子)
  5. 新电子书:解决生产中Java应用程序错误的完整指南
  6. 高速信号传输约翰逊 pdf_智芯文库 | 高速数字电路的设计与仿真
  7. 如何以用户身份登录MySQL_解析:如何以普通用户的身份运行 MySQL
  8. 剑指offer面试题58 - II. 左旋转字符串(切片)(一行代码)
  9. JWT、OAuth 2.0、session 用户授权实战
  10. 汇编语言:基本指令详解
  11. 信息安全技术--轮转机密码
  12. android绑定交通卡,【NFC-SIM卡刷公交教程】支持安卓8.0(3月23日更新)
  13. 2018/7/18 HDU 5294 Tricks Device 最短路建图+最小割 训练日记2
  14. java中stringBuilder的用法(转)
  15. java查看jar包源代码_如何查看 JAR 包的源代码
  16. Android - 制作聊天气泡.9格式
  17. 雷达感应智能化技术,让家居生活更智能,雷达传感器技术应用
  18. 记录redis Connection timed out处理(关于THP的处理)
  19. 2021CCPC河南省赛赛后总结(终于拿金了呜呜呜)
  20. 能让人瞬间高兴的30件最开心的事

热门文章

  1. ElasticSearch实战(三十六)-Ingest Pipeline 多管道处理器
  2. [C#] 使用 NAudio 实现音频可视化
  3. 计算机无法更新正在撤销更改,win10更新出现“无法完成更新正在撤销更改请不要关闭计算”怎么办...
  4. Python+OpenCV利用KNN背景分割器进行静态场景行人检测与轨迹跟踪
  5. Practice II 字符串
  6. ASM、AAM算法介绍
  7. AAM(Active Appearance Model)算法介绍
  8. php代码出现notice,PHP提示Notice: Undefined variable的解决办法
  9. R语言实战笔记 基本统计分析-频数列联表和简单的独立性检验
  10. JavaScript 入门(一)