SMBMS项目-准备工作
项目搭建准备工作
1、基础准备工作
- 搭建一-个maven web项目
- 配置Tomcat
- 测试项目是否能够跑起来
- 导入项目中会遇到的jar包
- jsp,Servlet,mysq|驱动, jstl, stand..
2、创建项目结构
3、编写实体类;
- ORM映射:表-类映射,pojo类
4、编写基础公共类
4.1数据库配置文件db.properties
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306?/smbms?useUnicode=true&characterEncoding=utf-8&serverTimeZone=GMT
user=root
password=123456
4.2编写数据库的公共类
public class BaseDao {
private static String driver;
private static String url;
private static String username;
private static String password;
static{
Properties properties=new Properties();
//通过类加载器加载资源
InputStream is = BaseDao.class.getClassLoader().getResourceAsStream("db.properties");
try {
properties.load(is);
} catch (IOException e) {
e.printStackTrace();
}
driver = properties.getProperty(driver);
url = properties.getProperty(url);
username = properties.getProperty(username);
password = properties.getProperty(password);
}
//获取数据库的连接
public static Connection getConnection(){
Connection connection=null;
try {
Class.forName(driver);
connection = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
e.printStackTrace();
}
return connection;
}
//编写查询公共类
public static ResultSet execute(Connection connection,String sql,Object[] params,ResultSet resultSet,PreparedStatement preparedStatement) throws SQLException {
preparedStatement = connection.prepareStatement(sql);
for (int i = 0; i <params.length ; i++) {
preparedStatement.setObject(i+1,params[i]);
}
resultSet = preparedStatement.executeQuery();
return resultSet;
}
//编写增删改的公共方法
public static int execute(Connection connection,String sql,Object[] params,PreparedStatement preparedStatement) throws SQLException {
preparedStatement = connection.prepareStatement(sql);
for (int i = 0; i <params.length ; i++) {
preparedStatement.setObject(i+1,params[i]);
}
int updateRows = preparedStatement.executeUpdate();
return updateRows;
}
//释放资源类
public static boolean closeResource(Connection connection,PreparedStatement preparedStatement,ResultSet resultSet){
boolean flag=true;
if (resultSet!=null){
try {
resultSet.close();
resultSet=null;
} catch (SQLException throwables) {
throwables.printStackTrace();
flag=false;
}
}
if (preparedStatement!=null){
try {
preparedStatement.close();
preparedStatement=null;
} catch (SQLException throwables) {
throwables.printStackTrace();
flag=false;
}
}
if (connection!=null){
try {
connection.close();
connection=null;
} catch (SQLException throwables) {
throwables.printStackTrace();
flag=false;
}
}
return false;
}
}
4.3编写字符编码过滤器,并在web.xml中注册
public class CharacterEncodingFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
req.setCharacterEncoding("utf-8");
resp.setCharacterEncoding("utf-8");
chain.doFilter(req,resp);
}
public void destroy() {
}
}
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>com.chao.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
5、导入静态资源
后续正在学习中。。。
if(随笔.hasnext()){
response.sendRedirect("/下一篇随笔");
}else{
Systom.out.println("菜鸡儿作者正在努力学习中,请稍后");
reader.wait();
}
SMBMS项目-准备工作的更多相关文章
- [2017BUAA软工助教]个人项目准备工作
BUAA软工个人项目准备工作 零.注册Github个人账号(你不会没有吧..) 这是Git的使用教程: http://www.cnblogs.com/schaepher/p/5561193.html ...
- Django商城项目笔记No.2项目准备工作
Django商城项目笔记No.2项目准备工作 接着上篇开始,创建好工程之后,随之而来的是怎么配置工程,这篇文章记录如何进行相关的配置 1.pycharm打开工程,进行相关的配置 通过pycharm打开 ...
- Django商城项目笔记No.1项目准备工作
Django商城项目笔记No.1项目准备工作 一.本项目商城属于B2C商业模式 二.项目采用前后端分离的应用模式 前端使用Vue.js 后端使用Django REST framework 1.创建gi ...
- smbms项目核心功能实现
SMBMS 数据库: 项目如何搭建? 考虑使用不使用Maven?依赖,Jar 1.项目搭建准备工作 搭建一个maven web项目 配置Tomcat 测试项目是否能够跑起来 导入项目中会遇到的jar包 ...
- ExtJS 项目准备工作(一)
首先,需要从网上下载两个文件,一个是SenchaCmd-6.2.0-windows-64bit(我的电脑是window 10 64位) 另一个是ExtJs6的源码包(ext-6.0.0.415). 源 ...
- 环境配置——tornado项目准备工作
新建tornado项目后,采用Pycharm作为开发工具,采用Xshell链接Ubuntu模拟服务端方便方便测试.项目编码前进行以下几个方面的配置. 1.Ubuntu配置 1.1安装ssh服务 sud ...
- vue项目准备工作
1.写文档: 产品说明.工作日志.接口说明文档.数据库说明文档.项目架构说明文档等···· 例如:后台管理系统:商品的管理.店铺的管理.店铺类别管理.管理员的管理.用户管理等····· 前端渲染 ...
- 基于SSM框架的简易的分页功能——包含maven项目的搭建
新人第一次发帖,有什么不对的地方请多多指教~~ 分页这个功能经常会被使用到,我之前学习的时候找了很多资源,可都看不懂(笨死算了),最后还是在朋友帮助下做出了这个分页.我现在把我所能想到的知识 做了一个 ...
- Mac下Intellij IDea发布Java Web项目详解四 为所有Module配置Tomcat Deployment
准备工作1:新建第一个JavaWeb项目 准备工作2:新建Module step5 为所有项目配置Deployment 5.1 如图 5.2 [+][Artifact] 5.3 将这里列出的所有内容选 ...
随机推荐
- 微信网页授权报code been used, hints: [ req_id: XYv1Ha07042046 ]
先贴上代码: public function index() { $code = input('get.code'); $tool = new Wxtool(); if (empty($code)) ...
- [函数] PHP取二进制文件头快速判断文件类型
一般我们都是按照文件扩展名来判断文件类型,但其实不太靠谱,因为可以通过修改扩展名来伪装文件类型.其实我们可以通过读取文件信息来识别,比如 PHP扩展中提供了类似 exif_imagetype 这样的函 ...
- 2019-2020-1 20199329《Linux内核原理与分析》第二周作业
<Linux内核原理与分析>第二周作业 一.上周问题总结: 未能及时整理笔记 Linux还需要多用 markdown格式不熟练 发布博客时间超过规定期限 二.本周学习内容: <庖丁解 ...
- linux sort 命令实用手册
Linux 中的sort 命令是一个很实用的工具,用于对文本内容以行为单位进行ASCII 码排序,默认按照升序进行排序(当然也可以按照降序). sort 命令的格式如下: sort `参数` `文件名 ...
- 抖音人脸识别Autojs脚本
title: 抖音人脸识别Autojs脚本 用Autojs写的抖音人脸颜值检测脚本 疫情期间宅家久了,昨天闲着没事(好吧,有事情,但是我不想做) ,消费之火熊熊燃烧.一咬牙把Autojs入正了.我 ...
- 透彻理解C++11新特性:右值引用、std::move、std::forward
目录 浅拷贝.深拷贝 左值.右值 右值引用类型 强转右值 std::move 重新审视右值引用 右值引用类型和右值的关系 函数参数传递 函数返还值传递 万能引用 引用折叠 完美转发 std::forw ...
- TensorFlow框架 入门笔记
背景 略 基础 介绍 略 TensorFlow安装 link TensorFlow 主要概念 使用图(graph)来表示计算任务(执行流程). 在被称之为会话(session)的上下文(context ...
- 二.Spring boot食用指南:结合Jpa(Hibernate) 构建MVC架构
1.POM依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w ...
- 爱创课堂每日一题第五十四天- 列举IE 与其他浏览器不一样的特性?
IE支持currentStyle,FIrefox使用getComputStyle IE 使用innerText,Firefox使用textContent 滤镜方面:IE:filter:alpha(op ...
- Mbatis逆向工程常遇错误
org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession.### The error may e ...