开发简单的JavaWeb项目
一。配置相关环境
下载配置JDK,eclipse,Tomcat服务器,Mysql数据库,Navicat for MySQL(数据库可视化工具)
如果你已经做好各个环境的配置,eclipse与Tomcat的连接,数据库配置环境等,就可以进行下一步了。
二。新建一个数据库如图
三。在eclipse中新建JavaWeb项目
文件-->新建-->项目-->Web下的Dynamic Web Project
一路next就可以了,记得勾选下图中的自动生成xml
自己按下图搭建项目结构,生成的项目结构如图
下一步,很关键的一步!!!下载mysql的jar包(mysql-connector-java-5.1.7-bin.jar),下载方法百度,很简单,把下载好的文件里的jar包复制到WEB-INF下的lib文件夹里。
四。代码
//Course.java
package com.hjf.entity; public class Course { private int id;
private String name;
private String teacher;
private String classroom; public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTeacher() {
return teacher;
}
public void setTeacher(String teacher) {
this.teacher = teacher;
}
public String getClassroom() {
return classroom;
}
public void setClassroom(String classroom) {
this.classroom = classroom;
} public Course() {} public Course(int id, String name, String teacher, String classroom) {
this.id = id;
this.name = name;
this.teacher = teacher;
this.classroom = classroom;
} public Course(String name, String teacher, String classroom) {
this.name = name;
this.teacher = teacher;
this.classroom = classroom;
}
}
//CourseDao.java
package com.hjf.dao; import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List; import com.hjf.entity.Course;
import com.hjf.util.DBUtil; /**
* 课程Dao
* Dao层操作数据
* @author Hu
*
*/
public class CourseDao { /**
* 添加
* @param course
* @return
*/
public boolean add(Course course) {
String sql = "insert into course(name, teacher, classroom) values('" + course.getName() + "','" + course.getTeacher() + "','" + course.getClassroom() + "')";
//创建数据库链接
Connection conn = DBUtil.getConn();
Statement state = null;
boolean f = false;
int a = 0; try {
state = conn.createStatement();
state.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
//关闭连接
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
} /**
* 删除
*
* @param id
* @return
*/
public boolean delete (int id) {
boolean f = false;
String sql = "delete from course where id='" + id + "'"; Connection conn = DBUtil.getConn();
Statement state = null;
int a = 0; try {
state = conn.createStatement();
a = state.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
} /**
* 修改
* @param name
* @param pass
*/
public boolean update(Course course) {
String sql = "update course set name='" + course.getName() + "', teacher='" + course.getTeacher() + "', classroom='" + course.getClassroom()
+ "' where id='" + course.getId() + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
boolean f = false;
int a = 0; try {
state = conn.createStatement();
a = state.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
} /**
* 验证课程名称是否唯一
* true --- 不唯一
* @param name
* @return
*/
public boolean name(String name) {
boolean flag = false;
String sql = "select name from course where name = '" + name + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
flag = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
}
return flag;
} /**
* 通过ID得到课程信息
* @param id
* @return
*/
public Course getCourseById(int id) {
String sql = "select * from course where id ='" + id + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
Course course = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
String name = rs.getString("name");
String teacher = rs.getString("teacher");
String classroom = rs.getString("classroom");
course = new Course(id, name, teacher, classroom);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return course;
} /**
* 通过name得到Course
* @param name
* @return
*/
public Course getCourseByName(String name) {
String sql = "select * from course where name ='" + name + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
Course course = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
int id = rs.getInt("id");
String teacher = rs.getString("teacher");
String classroom = rs.getString("classroom");
course = new Course(id, name, teacher, classroom);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return course;
} /**
* 查找
* @param name
* @param teacher
* @param classroom
* @return
*/
public List<Course> search(String name, String teacher, String classroom) {
String sql = "select * from course where ";
if (name != "") {
sql += "name like '%" + name + "%'";
}
if (teacher != "") {
sql += "teacher like '%" + teacher + "%'";
}
if (classroom != "") {
sql += "classroom like '%" + classroom + "%'";
}
List<Course> list = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
Course bean = null;
while (rs.next()) {
int id = rs.getInt("id");
String name2 = rs.getString("name");
String teacher2 = rs.getString("teacher");
String classroom2 = rs.getString("classroom");
bean = new Course(id, name2, teacher2, classroom2);
list.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return list;
} /**
* 全部数据
* @param name
* @param teacher
* @param classroom
* @return
*/
public List<Course> list() {
String sql = "select * from course";
List<Course> list = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
Course bean = null;
while (rs.next()) {
int id = rs.getInt("id");
String name2 = rs.getString("name");
String teacher2 = rs.getString("teacher");
String classroom2 = rs.getString("classroom");
bean = new Course(id, name2, teacher2, classroom2);
list.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return list;
} } //CourseService.java
package com.hjf.service; import java.util.List; import com.hjf.dao.CourseDao;
import com.hjf.entity.Course; /**
* CourseService
* 服务层
* @author Hu
*
*/
public class CourseService { CourseDao cDao = new CourseDao(); /**
* 添加
* @param course
* @return
*/
public boolean add(Course course) {
boolean f = false;
if(!cDao.name(course.getName())) {
cDao.add(course);
f = true;
}
return f;
} /**
* 删除
*/
public void del(int id) {
cDao.delete(id);
} /**
* 修改
* @return
*/
public void update(Course course) {
cDao.update(course);
} /**
* 通过ID得到一个Course
* @return
*/
public Course getCourseById(int id) {
return cDao.getCourseById(id);
} /**
* 通过Name得到一个Course
* @return
*/
public Course getCourseByName(String name) {
return cDao.getCourseByName(name);
} /**
* 查找
* @return
*/
public List<Course> search(String name, String teacher, String classroom) {
return cDao.search(name, teacher, classroom);
} /**
* 全部数据
* @return
*/
public List<Course> list() {
return cDao.list();
}
} //CourseServlet.java
package com.hjf.servlet; import java.io.IOException;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.hjf.entity.Course;
import com.hjf.service.CourseService; @WebServlet("/CourseServlet")
public class CourseServlet extends HttpServlet { private static final long serialVersionUID = 1L; CourseService service = new CourseService(); /**
* 方法选择
*/
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String method = req.getParameter("method"); if ("add".equals(method)) {
add(req, resp);
} else if ("del".equals(method)) {
del(req, resp);
} else if ("update".equals(method)) {
update(req, resp);
} else if ("search".equals(method)) {
search(req, resp);
} else if ("getcoursebyid".equals(method)) {
getCourseById(req, resp);
} else if ("getcoursebyname".equals(method)) {
getCourseByName(req, resp);
} else if ("list".equals(method)) {
list(req, resp);
}
} /**
* 添加
* @param req
* @param resp
* @throws IOException
* @throws ServletException
*/
private void add(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
req.setCharacterEncoding("utf-8");
//获取数据
String name = req.getParameter("name");
String teacher = req.getParameter("teacher");
String classroom = req.getParameter("classroom");
Course course = new Course(name, teacher, classroom); //添加后消息显示
if(service.add(course)) {
req.setAttribute("message", "添加成功");
req.getRequestDispatcher("add.jsp").forward(req,resp);
} else {
req.setAttribute("message", "课程名称重复,请重新录入");
req.getRequestDispatcher("add.jsp").forward(req,resp);
}
} /**
* 全部
* @param req
* @param resp
* @throws ServletException
*/
private void list(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8"); List<Course> courses = service.list();
req.setAttribute("courses", courses);
req.getRequestDispatcher("list.jsp").forward(req,resp);
} /**
* 通过ID得到Course
* @param req
* @param resp
* @throws ServletException
*/
private void getCourseById(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
Course course = service.getCourseById(id);
req.setAttribute("course", course);
req.getRequestDispatcher("detail2.jsp").forward(req,resp);
} /**
* 通过名字查找
* 跳转至删除
* @param req
* @param resp
* @throws IOException
* @throws ServletException
*/
private void getCourseByName(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
String name = req.getParameter("name");
Course course = service.getCourseByName(name);
if(course == null) {
req.setAttribute("message", "查无此课程!");
req.getRequestDispatcher("del.jsp").forward(req,resp);
} else {
req.setAttribute("course", course);
req.getRequestDispatcher("detail.jsp").forward(req,resp);
}
} /**
* 删除
* @param req
* @param resp
* @throws IOException
* @throws ServletException
*/
private void del(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
service.del(id);
req.setAttribute("message", "删除成功!");
req.getRequestDispatcher("del.jsp").forward(req,resp);
} /**
* 修改
* @param req
* @param resp
* @throws IOException
* @throws ServletException
*/
private void update(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
String name = req.getParameter("name");
String teacher = req.getParameter("teacher");
String classroom = req.getParameter("classroom");
Course course = new Course(id, name, teacher, classroom); service.update(course);
req.setAttribute("message", "修改成功");
req.getRequestDispatcher("CourseServlet?method=list").forward(req,resp);
} /**
* 查找
* @param req
* @param resp
* @throws ServletException
*/
private void search(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
String name = req.getParameter("name");
String teacher = req.getParameter("teacher");
String classroom = req.getParameter("classroom");
List<Course> courses = service.search(name, teacher, classroom);
req.setAttribute("courses", courses);
req.getRequestDispatcher("searchlist.jsp").forward(req,resp);
}
} //DBUtil.java
package com.hjf.util; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; /**
* 数据库连接工具
* @author Hu
*
*/
public class DBUtil { public static String db_url = "jdbc:mysql://localhost:3306/course";
public static String db_user = "root";
public static String db_pass = "root"; public static Connection getConn () {
Connection conn = null; try {
Class.forName("com.mysql.jdbc.Driver");//加载驱动
conn = DriverManager.getConnection(db_url, db_user, db_pass);
} catch (Exception e) {
e.printStackTrace();
} return conn;
} /**
* 关闭连接
* @param state
* @param conn
*/
public static void close (Statement state, Connection conn) {
if (state != null) {
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} public static void close (ResultSet rs, Statement state, Connection conn) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
} if (state != null) {
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} public static void main(String[] args) throws SQLException {
Connection conn = getConn();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql ="select * from course";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next()){
System.out.println("空");
}else{
System.out.println("不空");
}
}
} //add.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title> </head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">课程信息录入</h1>
<a href="index.jsp">返回主页</a>
<form action="CourseServlet?method=add" method="post" onsubmit="return check()">
<div class="a">
课程名称<input type="text" id="name" name="name"/>
</div>
<div class="a">
任课教师<input type="text" id="teacher" name="teacher" />
</div>
<div class="a">
上课地点<input type="text" id="classroom" name="classroom" />
</div>
<div class="a">
<button type="submit" class="b">保 存</button>
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var name = document.getElementById("name");;
var teacher = document.getElementById("teacher");
var classroom = document.getElementById("classroom"); //非空
if(name.value == '') {
alert('课程名称为空');
name.focus();
return false;
}
if(teacher.value == '') {
alert('教师为空');
teacher.focus();
return false;
}
if(classroom.value == '') {
alert('上课地点为空');
classroom.focus();
return false;
} //教师
if(teacher.value != '王建民' && teacher.value != '王辉' && teacher.value != '刘丹' && teacher.value != '刘立嘉' && teacher.value != '杨子光'){
alert('教师名称错误');
return false;
} //教室
if(!/^基教/.test(classroom.value) && !/^一教/.test(classroom.value) && !/^二教/.test(classroom.value) && !/^三教/.test(classroom.value)) {
alert('上课地点错误');
return false;
}
}
</script>
</body>
</html> //del.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title> </head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">课程信息删除</h1>
<a href="index.jsp">返回主页</a>
<form action="deleteservlet" method="post" onsubmit="return check()">
<div class="a">
课程名称<input type="text" id="classname" name="classname"/>
</div>
<div class="a">
<button type="submit" class="b">查 找</button>
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var name = document.getElementById("classname");; //非空
if(name.value == '') {
alert('课程名称为空');
name.focus();
return false;
}
}
</script>
</body>
</html> //detail.jap
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
width: 160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: black;">课程信息删除</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>课程名称</td>
<td>${list.classname}</td>
</tr>
<tr>
<td>任课教师</td>
<td>${list.teachnamr}</td>
</tr>
<tr>
<td>上课地点</td>
<td>${list.site}</td>
</tr>
</table>
<div class="a">
<a onclick="return check()" href="deleteservlet?method=post">删 除</a>
</div>
</div>
<script type="text/javascript">
function check() {
if (confirm("真的要删除吗?")){
return true;
}else{
return false;
}
}
</script>
</body>
</html> //detail2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title> </head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">课程信息修改</h1>
<a href="index.jsp">返回主页</a>
<form action="CourseServlet?method=update" method="post" onsubmit="return check()">
<div class="a">
课程名称<input type="text" id="name" name="name" value="${course.name}"/>
</div>
<div class="a">
任课教师<input type="text" id="teacher" name="teacher" value="${course.teacher}"/>
</div>
<div class="a">
上课地点<input type="text" id="classroom" name="classroom" value="${course.classroom}"/>
</div>
<input type="hidden" id="id" name="id" value="${course.id}"/>
<div class="a">
<button type="submit" class="b">修 改</button>
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var name = document.getElementById("name");;
var teacher = document.getElementById("teacher");
var classroom = document.getElementById("classroom"); //非空
if(name.value == '') {
alert('课程名称为空');
name.focus();
return false;
}
if(teacher.value == '') {
alert('教师为空');
teacher.focus();
return false;
}
if(classroom.value == '') {
alert('上课地点为空');
classroom.focus();
return false;
} //教师
if(teacher.value != '王建民' && teacher.value != '王辉' && teacher.value != '刘丹' && teacher.value != '刘立嘉' && teacher.value != '杨子光'){
alert('教师名称错误');
return false;
} //教室
if(!/^基教/.test(classroom.value) && !/^一教/.test(classroom.value) && !/^二教/.test(classroom.value) && !/^三教/.test(classroom.value)) {
alert('上课地点错误');
return false;
}
}
</script>
</body>
</html> //index.jsp <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页</title> </head>
<body>
<div align="center"> <div class="a">
<a href="add.jsp">课程信息添加</a>
</div>
<div class="a">
<a href="CourseServlet?method=list">课程信息修改</a>
</div>
<div class="a">
<a href="del.jsp">课程信息删除</a>
</div>
<div class="a">
<a href="search.jsp">课程信息查询</a>
</div>
</div>
</body>
</html> //list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title> </head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">课程信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>课程名称</td>
<td>任课教师</td>
<td>上课地点</td>
<td align="center" colspan="2">操作</td>
</tr>
<c:forEach items="${courses}" var="item">
<tr>
<td>${item.id}</td>
<td>${item.name}</td>
<td>${item.teacher}</td>
<td>${item.classroom}</td>
<td><a href="CourseServlet?method=getcoursebyid&id=${item.id}">修改</a></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html> //search.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title> </head>
<body>
<div align="center">
<h1 style="color: black;">课程信息查询</h1>
<a href="index.jsp">返回主页</a>
<form action="CourseServlet?method=search" method="post" onsubmit="return check()">
<div class="a">
课程名称<input type="text" id="name" name="name"/>
</div>
<div class="a">
任课教师<input type="text" id="teacher" name="teacher" />
</div>
<div class="a">
上课地点<input type="text" id="classroom" name="classroom" />
</div>
<div class="a">
<button type="submit" class="b">查 询</button>
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var name = document.getElementById("name");;
var teacher = document.getElementById("teacher");
var classroom = document.getElementById("classroom"); //非空
if(name.value == '' && teacher.value == '' && classroom.value == '') {
alert('请填写一个条件');
return false;
}
}
</script>
</body>
</html> //searchlist.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title> </head>
<body>
<div align="center">
<h1 style="color: black;">课程信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>课程名称</td>
<td>任课教师</td>
<td>上课地点</td>
</tr>
<!-- forEach遍历出adminBeans -->
<c:forEach items="${courses}" var="item" varStatus="status">
<tr>
<td>${item.id}</td>
<td><a>${item.name}</a></td>
<td>${item.teacher}</td>
<td>${item.classroom}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
开发简单的JavaWeb项目的更多相关文章
- 如何开发简单的javaweb项目,jsp+javabean+servlet
一.相关的软件下载和环境配置 1.下载并配置JDK. 2.下载eclipse. 3.下载并配置apache-tomcat(服务器). 4.下载MySQL(数据库). 5.下载Navicat for M ...
- (一)使用IDEA新建一个最简单的JavaWeb项目,Maven管理
1.项目环境 IDEA:2016.2 JDK:1.8.0_76 Maven:3.2.5 2.File-->New-->Project-->Maven 3.选择Project SDK: ...
- 简单转java-web项目
- 一个简单的javaweb项目模板
Controller包:表现层(视图)层.用来显示数据和接收用户数据 Service包:业务逻辑层,用来处理页面.先写接口,后写实现类 Dao包:持久层(数据访问层).用来操作数据库 其中Dao包处于 ...
- 用Eclipse 创建一个 简单的 Maven JavaWeb 项目
使用Maven 创建一个简单的 javaWeb 项目: 本篇属于 创建 JavaWeb 项目的第三篇: 建议阅读本篇之前 阅读 用 Eclipse 创建一个简单的web项目 ;本篇是这这篇文章的基础 ...
- ubuntu16.04环境下在docker上部署javaweb项目简单案例
因为一些原因,接触到了docker,经过一番研究,总算是有了一些自己的看法,有什么不对的地方,希望多多指教. 废话不多说,首先我这里使用的虚拟机安装的是ubuntu16.04版本,其他版本应该也可以. ...
- Tomcat 运行 idea 编译好的 .class JavaWeb 项目
对于新手来说,对于项目部署,有时候就是以为拷贝在idea控制台里面跑的项目放到tomcat里面的webapps里面跑就可以了,这仅仅限于静态项目..... 他不像PHP , 修改源码直接可以跑, 而J ...
- Javaweb项目开发的前后端解耦的必要性
JavaWeb项目为何我们要放弃jsp?为何要前后端解耦?为何要动静分离? 使用jsp的痛点: 1.jsp上动态资源和静态资源全部耦合在一起,服务器压力大,因为服务器会收到各种静态资源的http请求, ...
- (转)一个JavaWeb项目开发总结
原文地址:http://www.cnblogs.com/lzb1096101803/p/4907775.html 一.学会如何读一个JavaWeb项目源代码 步骤:表结构->web.xml-&g ...
随机推荐
- matlab读取excel里的数据并用imagesc画图
把矩阵数据保存在excel里 比如文件为 a.xlsx 通过下面的程序读取 a=xlsread('\文件保存的目录\a.xlsx'); figure(1); imagesc(a) colormap(h ...
- AI图谱
- 【转】iOS 自动化性能采集
前言 对于iOS总体生态是比较封闭的,相比Android没有像adb这种可以查看内存.cpu的命令.在日常做性能测试,需要借助xcode中instruments查看内存.cpu等数据. 但是借助i ...
- 微信小程序开发——苹果手机领取卡券出现参数错误(安卓正常)
异常描述: 微信小程序领取卡券,调用 wx.addCard 接口,安卓手机正常调起领取卡券界面,苹果手机.微信开发者工具中均出现“参数错误”,如图: 异常解析: 安卓手机能正常调起领取界面,那就说明领 ...
- 写了一个兼容IE9的图片放大器(基于vue)
photoloupe 图片放大器 第一次写vue插件,本人比较喜欢用简单易懂的写法,不喜勿喷. 本插件支持IE9及以上版本,已经过验证. 本插件可根据需要设置放大倍数,最小支持1倍,支持小数 下载地址 ...
- java链接JDBC中的?问题
String sql = "select * from student where name= ?"; PreparedStatement pst = conn.prepareSt ...
- Netty---入门程序,搭建Websocket 服务器
Netty 常用的场景: 1.充当HTTP 服务器,但Netty 并没有遵循servlet 的标准,反而实现了自己的一套标准进行Http 服务: 2,RPC 远程调用,在分布式系统中常用的框架 3.S ...
- mysql中的 随机字符串的生成
方法1. SELECT SUBSTRING(MD5(RAND()),FLOOR(RAND()*26)+1,6) AS rand_str; 上诉示例产生的是:6位长度的随机字符串. 函数解释: rand ...
- Tomcat配置远程调试端口(windows、Linux)
当我们需要定位生产环境问题,而日志又不清晰的情况下,我们可以借助Tomcat提供的远程调试,设置如下: // Linxu系统: apach/bin/startup.sh开始处中增加如下内容: decl ...
- stark组件开发之列表页面预留钩子方法。 可根据用户的不同,显示不同的列
要实现,这个方法.子类中 list_diplay 这个列表, 就不能够写死.他应该是 可以根据.用户的不同,返回不同的值. 所以 就需要一个函数, 可以进行判断当前用户是谁. 并且往这个列表中添加,他 ...