java关键字“this”只能用在方法方法体内。当一个对象创建之后,java虚拟机就会给这个对象分配一个引用自身的指针,这个指针的名字就是this。只能在非静态方法中使用

 package servlet;

 import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class GetInitParameterServlet extends HttpServlet { private String username;//用户名
private String password;//密码 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;
} /**
* Constructor of the object.
*/
public GetInitParameterServlet() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} /**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { doPost(request,response);
} /**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println("<h2>"+"用户名:"+this.getUsername()+"</h2>");
out.println("<h2>"+"密码:"+this.getPassword()+"</h2>");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
this.setUsername(this.getInitParameter("username"));
this.setPassword(this.getInitParameter("password"));
} }

web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>GetInitParameterServlet</servlet-name>
<servlet-class>servlet.GetInitParameterServlet</servlet-class>
<init-param>
<param-name>username</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>123456</param-value>
</init-param>
</servlet> <servlet-mapping>
<servlet-name>GetInitParameterServlet</servlet-name>
<url-pattern>/servlet/GetInitParameterServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
 <%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head> <body>
<h1>获取初始化参数演示案例</h1>
<hr>
<a href="servlet/GetInitParameterServlet">获取初始化参数servlet</a>
</body>
</html>

设计类的时候主要考虑两方面因素:设计这个类的属性和方法

entity:实体层

集合类型:序列、set、hashset

购买商品的集合:用Map类型表示购买商品的集合,键:商品对象,值:商品购买的数量

键:Items商品类型,值:Integer购买的数量

代码实现:

 package entity;

 import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set; //购物车类
public class Cart {
//购买商品的集合
private HashMap<Items,Integer> goods;
//购物车的总金额
private double totalPrice;
//构造方法
public Cart() {
//初始化属性
goods = new HashMap<Items,Integer>();
totalPrice=0.0;
}
public HashMap<Items, Integer> getGoods() {
return goods;
}
public void setGoods(HashMap<Items, Integer> goods) {
this.goods = goods;
}
public double getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(double totalPrice) {
this.totalPrice = totalPrice;
} //添加商品进购物车的方法
public boolean addGoodsInCart(Items item,int number)//参数:商品对象item,商品数量number
{//判断购物车是否包含该商品
if(goods.containsKey(item))//如果此映射包含对于指定键的映射关系,则返回 true。
{
goods.put(item, goods.get(item)+number);//在此映射中关联指定值与指定键。
}
else{//第一次购买这个商品
goods.put(item, number);
}
//当你添加和删除商品之后,都应该重新计算购物车的总金额
calTotalPrice();//重新计算购物车的总金额
return true;
} //删除商品的方法
public boolean removeGoodsFromCart(Items item)
{
goods.remove(item);//从此映射中移除指定键的映射关系(如果存在)。
calTotalPrice();//重新计算购物车的总金额
return true;
} //统计购物车的总金额
public double calTotalPrice(){ double sum=0.0;
//遍历Map类型的集合
Set<Items> keys=goods.keySet();//获得键的集合
//set类型用for循环是没法遍历的,必须使用迭代器
Iterator<Items> it=keys.iterator();//获得迭代器对象
//Iterator用while遍历
while(it.hasNext()){
//遍历商品对象
Items i=it.next();
//计算总价格:单价*购买数量
sum+=i.getPrice()*goods.get(i);//调用get方法取得每个键对应的value
}
this.setTotalPrice(sum);//设置购物车的总金额
return this.getTotalPrice();//返回总金额
}
public static void main(String[] args){
//先创建两个商品对象
Items i1 = new Items(1,"沃特篮球鞋","温州",200,500,"001.jpg");
Items i2 = new Items(2,"李宁运动鞋","广州",300,500,"002.jpg");
Items i3 = new Items(1,"沃特篮球鞋","温州",200,500,"001.jpg"); Cart c = new Cart();
c.addGoodsInCart(i1, 1);
c.addGoodsInCart(i2, 2);
//再次购买沃特篮球鞋,购买3双
c.addGoodsInCart(i3, 3); // 通过entrySet方法,返回Map中的所有键值对
//遍历购物商品的集合
Set<Map.Entry<Items, Integer>> items= c.getGoods().entrySet();//Entry<Items, Integer>键值对对象
for(Map.Entry<Items, Integer> obj:items)
{
System.out.println(obj);
} System.out.println("购物车的总金额:"+c.getTotalPrice());
} }

重写Items类中的两个方法:equals(Object),hashCode()

     //改写hashCode生成规则
@Override
public int hashCode() {//hashCode是这个对象的哈希码
// TODO Auto-generated method stub
return this.getId()+this.getName().hashCode();//商品的编号、商品的名称如果这两个都相同,那生成的hashCode也相同(相同的字符串,hashCode也相同)
} //判断这两个对象的内容是否相同
@Override
public boolean equals(Object obj) {
// 如果当前对象就等于传进来的对象,则这是两个相同的对象
if(this==obj){
return true;
} //判断是否属于商品类
if(obj instanceof Items){//使用 instanceof 判断一个实例是否属于某种类型
Items i=(Items)obj;
//判断商品编号和商品名称都和当前商品完全一样的话,要比较的商品对象和我自身的这个对象它的内容是相同的
if(this.getId()==i.getId()&&this.getName().equals(i.getName())){
return true;
}
else
{
return false;
}
}
else{
return false;
}
}

编写Servlet:添加商品进购物车

path是项目的根目录,服务器的根目录:WebRoot

代码实现:

 package servlet;

 import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import dao.ItemsDAO;
import entity.Cart;
import entity.Items; public class CartServlet extends HttpServlet { private String action ; //表示购物车的动作 ,add,show,delete
//商品业务逻辑类的对象
private ItemsDAO idao = new ItemsDAO(); /**
* Constructor of the object.
*/
public CartServlet() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} /**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
} /**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
if(request.getParameter("action")!=null)
{
this.action = request.getParameter("action");
if(action.equals("add")) //如果是添加商品进购物车
{
if(addToCart(request,response))
{
request.getRequestDispatcher("/success.jsp").forward(request, response);
}
else
{
request.getRequestDispatcher("/failure.jsp").forward(request, response);
}
}
if(action.equals("show"))//如果是显示购物车
{
request.getRequestDispatcher("/cart.jsp").forward(request, response);
}
if(action.equals("delete")) //如果是执行删除购物车中的商品
{
if(deleteFromCart(request,response))
{
request.getRequestDispatcher("/cart.jsp").forward(request, response);
}
else
{
request.getRequestDispatcher("/cart.jsp").forward(request, response);
}
}
} } //添加商品进购物车的方法
private boolean addToCart(HttpServletRequest request, HttpServletResponse response)
{//商品id
String id = request.getParameter("id");
//商品数量
String number = request.getParameter("num");
//商品资料
Items item = idao.getItemsById(Integer.parseInt(id));//Integer.parseInt(id)转换成整型 //是否是第一次给购物车添加商品,需要给session中创建一个新的购物车对象
if(request.getSession().getAttribute("cart")==null)
{
Cart cart = new Cart();
//填到session当中
request.getSession().setAttribute("cart",cart);
}
//获得session对象
Cart cart = (Cart)request.getSession().getAttribute("cart");
if(cart.addGoodsInCart(item, Integer.parseInt(number)))//Integer.parseInt(number)字符串类型强转成int类型
{
return true;
}
else
{
return false;
} } //从购物车中删除商品
private boolean deleteFromCart(HttpServletRequest request, HttpServletResponse response)
{
String id = request.getParameter("id");
Cart cart = (Cart)request.getSession().getAttribute("cart");
Items item = idao.getItemsById(Integer.parseInt(id));
if(cart.removeGoodsFromCart(item))
{
return true;
}
else
{
return false;
}
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
} }

detail.jsp

 <%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%@ page import="entity.Items"%>
<%@ page import="dao.ItemsDAO"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'details.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link href="css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/lhgcore.js"></script>
<script type="text/javascript" src="js/lhgdialog.js"></script>
<script type="text/javascript">
function selflog_show(id)//id要购买的商品编号 ,num购买商品数量,&action=add添加商品进购物车,path是项目的根目录,服务器的根目录:WebRoot
{
var num = document.getElementById("number").value;
J.dialog.get({id: 'haoyue_creat',title: '购物成功',width: 600,height:400, link: '<%=path%>/servlet/CartServlet?id='+id+'&num='+num+'&action=add', cover:true});
}
function add()
{
var num = parseInt(document.getElementById("number").value);
if(num<100)
{
document.getElementById("number").value = ++num;
}
}
function sub()
{
var num = parseInt(document.getElementById("number").value);
if(num>1)
{
document.getElementById("number").value = --num;
}
} </script> <style type="text/css">
hr{ border-color:FF7F00;
} div{
float:left;
margin-left: 30px;
margin-right:30px;
margin-top: 5px;
margin-bottom: 5px; }
div dd{
margin:0px;
font-size:10pt;
}
div dd.dd_name
{
color:blue;
}
div dd.dd_city
{
color:#000;
}
div #cart
{
margin:0px auto;
text-align:right;
}
span{
padding:0 2px;border:1px #c0c0c0 solid;cursor:pointer;
}
a{
text-decoration: none;
}
</style>
</head> <body>
<h1>商品详情</h1>
<a href="index.jsp">首页</a> >> <a href="index.jsp">商品列表</a>
<hr>
<center>
<table width="750" height="60" cellpadding="0" cellspacing="0" border="0">
<tr>
<!-- 商品详情 -->
<%
ItemsDAO itemDao = new ItemsDAO();
Items item = itemDao.getItemsById(Integer.parseInt(request.getParameter("id")));
if(item!=null)
{
%>
<td width="70%" valign="top">
<table>
<tr>
<td rowspan="5"><img src="data:images/<%=item.getPicture()%>" width="200" height="160"/></td>
</tr>
<tr>
<td><B><%=item.getName() %></B></td>
</tr>
<tr>
<td>产地:<%=item.getCity()%></td>
</tr>
<tr>
<td>价格:<%=item.getPrice() %>¥</td>
</tr>
<tr>
<td>购买数量:<span id="sub" onclick="sub();">-</span><input type="text" id="number" name="number" value="1" size="2"/><span id="add" onclick="add();">+</span></td>
</tr>
</table>
<div id="cart">
<img src="data:images/buy_now.png"><a href="javascript:selflog_show(<%=item.getId()%>)"><img src="data:images/in_cart.png"></a><a href="servlet/CartServlet?action=show"><img src="data:images/view_cart.jpg"/></a>
</div>
</td>
<%
}
%>
<%
String list ="";
//从客户端获得Cookies集合
Cookie[] cookies = request.getCookies();
//遍历这个Cookies集合
if(cookies!=null&&cookies.length>0)
{
for(Cookie c:cookies)
{
if(c.getName().equals("ListViewCookie"))
{
list = c.getValue();
}
}
} list+=request.getParameter("id")+",";
//如果浏览记录超过1000条,清零.
String[] arr = list.split(",");
if(arr!=null&&arr.length>0)
{
if(arr.length>=1000)
{
list="";
}
}
Cookie cookie = new Cookie("ListViewCookie",list);
response.addCookie(cookie); %>
<!-- 浏览过的商品 -->
<td width="30%" bgcolor="#EEE" align="center">
<br>
<b><font color="#FF7F00">您浏览过的商品</font></b><br>
<!-- 循环开始 -->
<%
ArrayList<Items> itemlist = itemDao.getViewList(list);
if(itemlist!=null&&itemlist.size()>0 )
{
System.out.println("itemlist.size="+itemlist.size());
for(Items i:itemlist)
{ %>
<div>
<dl>
<dt>
<a href="details.jsp?id=<%=i.getId()%>"><img src="data:images/<%=i.getPicture() %>" width="120" height="90" border="1"/></a>
</dt>
<dd class="dd_name"><%=i.getName() %></dd>
<dd class="dd_city">产地:<%=i.getCity() %>&nbsp;&nbsp;价格:<%=i.getPrice() %> ¥ </dd>
</dl>
</div>
<%
}
}
%>
<!-- 循环结束 -->
</td>
</tr>
</table>
</center>
</body>
</html>

success.jsp

 <%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%@ page import="entity.Items"%>
<%@ page import="dao.ItemsDAO"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'details.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link href="css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/lhgcore.js"></script>
<script type="text/javascript" src="js/lhgdialog.js"></script>
<script type="text/javascript">
function selflog_show(id)//id要购买的商品编号 ,num购买商品数量,&action=add添加商品进购物车,path是项目的根目录,服务器的根目录:WebRoot
{
var num = document.getElementById("number").value;
J.dialog.get({id: 'haoyue_creat',title: '购物成功',width: 600,height:400, link: '<%=path%>/servlet/CartServlet?id='+id+'&num='+num+'&action=add', cover:true});
}
function add()
{
var num = parseInt(document.getElementById("number").value);
if(num<100)
{
document.getElementById("number").value = ++num;
}
}
function sub()
{
var num = parseInt(document.getElementById("number").value);
if(num>1)
{
document.getElementById("number").value = --num;
}
} </script> <style type="text/css">
hr{ border-color:FF7F00;
} div{
float:left;
margin-left: 30px;
margin-right:30px;
margin-top: 5px;
margin-bottom: 5px; }
div dd{
margin:0px;
font-size:10pt;
}
div dd.dd_name
{
color:blue;
}
div dd.dd_city
{
color:#000;
}
div #cart
{
margin:0px auto;
text-align:right;
}
span{
padding:0 2px;border:1px #c0c0c0 solid;cursor:pointer;
}
a{
text-decoration: none;
}
</style>
</head> <body>
<h1>商品详情</h1>
<a href="index.jsp">首页</a> >> <a href="index.jsp">商品列表</a>
<hr>
<center>
<table width="750" height="60" cellpadding="0" cellspacing="0" border="0">
<tr>
<!-- 商品详情 -->
<%
ItemsDAO itemDao = new ItemsDAO();
Items item = itemDao.getItemsById(Integer.parseInt(request.getParameter("id")));
if(item!=null)
{
%>
<td width="70%" valign="top">
<table>
<tr>
<td rowspan="5"><img src="data:images/<%=item.getPicture()%>" width="200" height="160"/></td>
</tr>
<tr>
<td><B><%=item.getName() %></B></td>
</tr>
<tr>
<td>产地:<%=item.getCity()%></td>
</tr>
<tr>
<td>价格:<%=item.getPrice() %>¥</td>
</tr>
<tr>
<td>购买数量:<span id="sub" onclick="sub();">-</span><input type="text" id="number" name="number" value="1" size="2"/><span id="add" onclick="add();">+</span></td>
</tr>
</table>
<div id="cart">
<img src="data:images/buy_now.png"><a href="javascript:selflog_show(<%=item.getId()%>)"><img src="data:images/in_cart.png"></a><a href="servlet/CartServlet?action=show"><img src="data:images/view_cart.jpg"/></a>
</div>
</td>
<%
}
%>
<%
String list ="";
//从客户端获得Cookies集合
Cookie[] cookies = request.getCookies();
//遍历这个Cookies集合
if(cookies!=null&&cookies.length>0)
{
for(Cookie c:cookies)
{
if(c.getName().equals("ListViewCookie"))
{
list = c.getValue();
}
}
} list+=request.getParameter("id")+",";
//如果浏览记录超过1000条,清零.
String[] arr = list.split(",");
if(arr!=null&&arr.length>0)
{
if(arr.length>=1000)
{
list="";
}
}
Cookie cookie = new Cookie("ListViewCookie",list);
response.addCookie(cookie); %>
<!-- 浏览过的商品 -->
<td width="30%" bgcolor="#EEE" align="center">
<br>
<b><font color="#FF7F00">您浏览过的商品</font></b><br>
<!-- 循环开始 -->
<%
ArrayList<Items> itemlist = itemDao.getViewList(list);
if(itemlist!=null&&itemlist.size()>0 )
{
System.out.println("itemlist.size="+itemlist.size());
for(Items i:itemlist)
{ %>
<div>
<dl>
<dt>
<a href="details.jsp?id=<%=i.getId()%>"><img src="data:images/<%=i.getPicture() %>" width="120" height="90" border="1"/></a>
</dt>
<dd class="dd_name"><%=i.getName() %></dd>
<dd class="dd_city">产地:<%=i.getCity() %>&nbsp;&nbsp;价格:<%=i.getPrice() %> ¥ </dd>
</dl>
</div>
<%
}
}
%>
<!-- 循环结束 -->
</td>
</tr>
</table>
</center>
</body>
</html>

failure.jsp

 <%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'success.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body>
<center>
<img src="data:images/add_cart_failure.jpg"/>
<hr> <br>
<br>
<br> </center>
</body>
</html>

显示购物车

商品删除

带有确认功能的对话框

JAVA遇见HTML——Servlet篇:应用MVC架构实现项目的更多相关文章

  1. JAVA遇见HTML——Servlet篇:Servlet基础

    代码实现: HelloServlet package servlet; import java.io.IOException; import java.io.PrintWriter; import j ...

  2. Java学习之Servlet篇

    <JAVA遇见HTML——Servlet篇> Servlet 生命周期:Servlet 加载--->实例化--->服务--->销毁. init():在Servlet的生命 ...

  3. JAVA遇见HTML——JSP篇(JavaBeans)

    1.像使用普通java类一样,创建javabean实例,利用构造方法创建实例 跟表单关联,“*”表示根据名称来进行匹配,就是根据表单所提交过来的参数的名字和Javabean当中的属性名字来进行一一匹配 ...

  4. C#中富文本编辑器Simditor带图片上传的全部过程(MVC架构的项目)

    描述:最近c#项目中使用富文本编辑器Simditor,记录一下以便以后查看. 注:此项目是MVC架构的. 1.引用文件 项目中引用相应的css和js文件,注意顺序不能打乱,否则富文本编辑器不会正常显示 ...

  5. (jsp+servlet+javabean )MVC架构

    MVC是三个单词的缩写,这三个单词分别为:模型.视图和控制. 使用的MVC的目的:在于将M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式.比如Windows系统资源管理器文件夹内容的显示方 ...

  6. Java遇见HTML——JSP篇之JavaWeb简介

    一.什么是WEB应用程序 Web应用程序是一种可以通过Web(互联网)访问的应用程序.Web应用程序的一个最大好处是用户很容易访问应用程序.用户只需要有浏览器即可,不需要再安装其他软件. 为什么要学习 ...

  7. 当Java遇见了Html--Servlet篇

    ###一.什么是servlet servlet是在服务器上运行的小程序.一个servlet就是一个 java类,并且通过"请求-响应"编程模型来访问的这个驻留在服务器内存里的程序. ...

  8. Java遇见HTML——JSP篇之商品浏览记录的实现

    一.项目总体介绍 使用Cookie实现商品浏览记录. 要实现这个程序采取的是Model1(Jsp+JavaBean)架构实现,具体步骤: 首先要有个数据库,商品表,操作数据库的一个类DBHelper类 ...

  9. Java遇见HTML——JSP篇之JSP基础语法

    一.JSP简介 JSP全名为Java Server Pages,Java服务器端页面,其根本是一个简化的Servlet设计,它实现了在Java中使用HTML标签.Jsp是一种动态网页技术标准,是在服务 ...

随机推荐

  1. JS CSS写下拉菜单 竖行

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. nginx之配置proxy_set_header问题梳理

    客户端请求web服务,客户端:ip:192.168.223.1 nginx作为反向代理服务器:192.168.223.136 nginx作为后端web服务器:192.168.223.137 前提条件: ...

  3. FAQ and discussed with adam

    1. About permuter index. url:  https://www.youtube.com/watch?v=j789k96g5aQ&list=PL0ZVw5-GryEkGAQ ...

  4. 说一说Unsafe魔法类

    这篇算是对 Unsafe 的一个总体概况,由于内容实在太多,后续会分开几篇文章对里面内容展开细讲 前言 Unsafe可以说是java的后门,类似西游记中的如来佛祖法力无边,Unsafe主要提供一些用于 ...

  5. 乐字节Java循环:循环控制和嵌套循环

    乐字节小乐上次讲完了Java反射,接下来小乐给大家讲述Java循环. 循环有以下四部分: 一.循环控制 1. do..while 直到型 ( 先执行后判断) ,结构为: 先执行循环体,后判断布尔表达式 ...

  6. 1.Cloudera Manager安装

    安装环境采用2台虚拟机进行,一台master, 一台slave1 先安装好centos 6.5 两台,并设置静态ip 怎么安装可以参考地址:https://jingyan.baidu.com/arti ...

  7. K8S从入门到放弃系列-(8)kube-apiserver 高可用配置

    摘要: 前面几篇文章,就是整个的master节点各组件的部署,上面我们提到过,k8s组件中,kube-controller-manager.kube-scheduler及etcd这三个服务高可用,都是 ...

  8. Spring之23:AbstractBeanFactory,Bean的加载

    <spring源码之:循环依赖> AbstractBeanFactory的作用:别名管理,单例创建与注册,工厂方法FactoryBean支持. 由图我们直接的看出,AbstractBean ...

  9. 模块 time 和 datetime

    目录 时间模块time datatime time 模块 datetime 模块 时间模块time datatime time 模块 在Python中,通常有这三种方式来表示时间:时间戳.元组(str ...

  10. flask使用tablib导出excel数据表

    在网页中常常有导出数据的需求,尤其是一下管理类平台.在flask中要导出excel数据表,通常可以使用xlwt库,创建文件并逐行写入数据,但是使用起来总是感觉很麻烦.tablib库相对操作更加方便. ...