目录
0、效果展示
??1、概述
2、搭建环境
3、数据表
?4、后端代码示例
5、前端代码示例
0、效果展示
1、概述
题目是企业资讯管理网站,采用B/S(服务器/浏览器)架构,应用javaweb技术,采用Mysql数据库,用java语言实现。它的主要功能需要Myeclipse 平台,Tomcat 服务器,以及普通的浏览器即可实现。旨在通过建立这样一个系统有效地解决传统企业资讯管理网站存在的一系列问题。
本系统要求实现以下功能:
1)公司产品:该页面是对企业产品的详细展示,点击进入后可以查看产品的详细信息
2)公司新闻:该页面是发布该企业内容新闻的详细信息,人们进入后可以以查看。
3)公司简介:该页面是对公司的介绍,包括各个部门的介绍。
4)留言板:会员登录后可以在网站上进行留言,并且查看留言。
5)会员中心:会员注册后可以登录网站,进行会员中心进行相关操作。
6)后台系统管理:登录后台点击系统管理,实现的功能有公告管理、发布公告、友情链接管理、网站留言管理、管理员设置、后台登录日志。
8)后台公司新闻管理:该模块是对新闻信息的管理,发布公司新闻信息等。
9)公司产品管理:该模块主要是发布公司产品信息、管理公司产品。
10)注册会员管理:该模块是对会员信息的管理,如会员名、注册时间、登录次数、上次登录时间等。
11)行业动态管理:该模块是查看、删除行业动态管理信息,如标题、发布时间、发布人、点击率等等。
12)公司简介管理:该模块是发布公司简介、管理公司简介。
2、搭建环境
本文以实现一个企业网站为目标,从环境搭建到编码实现全过程讲述
我们使用javaweb、J2EE来构建企业网站,环境使用最新版jdk和tomcat,配合mysql数据库
开发工具使用idea(也可以使用eclipse),数据库管理工具使用Navicat Premium
开发框架使用JavaBean Servlet MVC结构;
没有使用SSH(Struts+Spring+Hibernate)或SSM(Spring+SpringMVC+MyBatis),这两个框架我们在别的项目中再介绍开发过程
在项目中会引入My97DatePicker作为前端日期时间选择工具,使用fckeditor作为富媒体编辑器(也可以使用百度的ueditor)
使用DWR(Direct Web Remoting)用于改善web页面与Java类交互,实现远程服务器端AJAX读取登录数据。
使用JSTL(Java server pages standarded tag library,即JSP标准标签库),此库是由JCP(Java community Proces)所制定的标准规范,它主要提供给Java Web开发人员一个标准通用的标签库,并由Apache的Jakarta小组来维护。开发人员可以利用这些标签取代JSP页面上的Java代码,从而提高程序的可读性,降低程序的维护难度。
3、数据表
表1 about 简介
字段名称 |
自动增长 |
字段类型 |
说明 |
id |
- |
int |
编号 |
name |
- |
varchar |
名称 |
content |
- |
varchar |
内容 |
addtime |
- |
datetime |
日期 |
表2 admin 管理员
字段名称 |
自动增长 |
字段类型 |
说明 |
|
id |
- |
int |
编号 |
|
username |
- |
varchar |
用户名 |
|
password |
- |
varchar |
密码 |
|
creattime |
- |
datetime |
日期 |
|
logintimes |
- |
int |
登录 日期 |
|
表3 affiche 公告
字段名称 |
自动增长 |
字段类型 |
说明 |
|
id |
- |
int |
编号 |
|
title |
- |
varchar |
标题 |
|
content |
- |
varchar |
内容 |
|
addtime |
- |
datetime |
日期 |
|
adder |
- |
varchar |
分布人 |
|
ifhide |
- |
int |
是否隐藏 |
|
表4 goods 产品
字段名称 |
自动增长 |
字段类型 |
说明 |
|
id |
- |
int |
编号 |
|
title |
- |
varchar |
标题 |
|
pic |
- |
varchar |
图片 |
|
content |
- |
varchar |
内容 |
|
addtime |
- |
datetime |
日期 |
|
adder |
- |
varchar |
发布人 |
|
ifhide |
- |
int |
是否隐藏 |
|
visit |
- |
int |
访问次数 |
|
?4、后端代码示例
package com.action;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 com.bean.ZhaopinBean;
import com.util.Constant;public class ZhaopinServlet extends HttpServlet {/*** Constructor of the object.*/public ZhaopinServlet() {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 {request.setCharacterEncoding(Constant.CHARACTERENCODING);response.setContentType(Constant.CONTENTTYPE);ZhaopinBean tb=new ZhaopinBean();String method=request.getParameter("method").trim();if(method.equals("upAbout")){String id=request.getParameter("id").trim();String name=request.getParameter("name");String content = request.getParameter("content").trim();int flag=tb.upAbout(id,name, content);if(flag == Constant.SUCCESS){request.setAttribute("message", "操作成功!");request.getRequestDispatcher("admin/about/index.jsp").forward(request, response);}else{request.setAttribute("message", "系统维护中,请稍后再试!");request.getRequestDispatcher("admin/about/index.jsp").forward(request, response);}}else if(method.equals("delAbout")){String id=request.getParameter("id").trim();int flag=tb.delAbout(id);if(flag == Constant.SUCCESS){request.setAttribute("message", "操作成功!");request.getRequestDispatcher("admin/about/index.jsp").forward(request, response);}else{request.setAttribute("message", "系统维护中,请稍后再试!");request.getRequestDispatcher("admin/about/index.jsp").forward(request, response);}}}/*** Initialization of the servlet. <br>** @throws ServletException if an error occure*/public void init() throws ServletException {// Put your code here}}
5、前端代码示例
<%@ page language="java" import="java.util.*,com.util.*" contentType="text/html;charset=gb2312" %><!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" class="ancient-ie old-ie no-js bit-html" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 7]>
<html id="ie7" class="ancient-ie old-ie no-js bit-html" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 8]>
<html id="ie8" class="old-ie no-js bit-html" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if IE 9]>
<html id="ie9" class="old-ie9 no-js bit-html" dir="ltr" lang="zh-CN">
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
<html class="no-js bit-html" dir="ltr" lang="zh-CN">
<!--<![endif]-->
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!-- for 360 --><meta name="renderer" content="webkit"><meta name="applicable-device" content="pc,mobile"><!-- for baidu --><meta http-equiv="Cache-Control" content="no-transform"/><!-- for baidu --><meta name="MobileOptimized" content="width"/><!-- for baidu --><meta name="HandheldFriendly" content="true"/><!-- for baidu --><!-- start of customer header --><!-- end of customer header --><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><title>企业资讯网站</title><link rel="stylesheet" href="css/respond.css" type="text/css" media="screen"/><link rel="stylesheet" href="css/css2.css" type="text/css" media="all"/><link rel='stylesheet' id='dt-main-css' href='css/main.css' type='text/css' media='all'/><link rel='stylesheet' id='dt-custom-less-css' href='css/custom.css' type='text/css' media='all'/><link rel='stylesheet' id='dt-bit-custom-less-css' href='css/bit-custom.css' type='text/css' media='all'/><link rel="stylesheet" href="css/css.css" type="text/css" media="all"/><link rel="stylesheet" href="css/media_screen.css" type="text/css" media="all"/><style>body {font-family: 微软雅黑;}</style><script type="text/javascript" src="js/jQuery1.10.2.min.js"></script></head><body class="page page-id-11290 page-child parent-pageid-6400 page-template-default image-blur btn-flat content-fullwidth wpb-js-composer js-comp-ver-4.0.1 vc_responsive" data-pid="11290" data-pkey="2916994a027b00c31b61cc8ebcc4b5c5"><div id="page" class=' breackall wide '><!-- left, center, classical, classic-centered --><!-- !Header --><%@ include file="iframe/head.jsp" %><%String message = (String)request.getAttribute("message");if(message == null){message = "";}if (!message.trim().equals("")){out.println("<script language='javascript'>");out.println("alert('"+message+"');");out.println("</script>");}request.removeAttribute("message");%><!-- #masthead --><section class="bitBanner" id="bitBanner" bitdatamarker="bitBanner" bitdataaction="site_fix_container"></section><div id="main" class="bit_main_content"><div class="main-gradient"></div><div class="wf-wrap"><div class="wf-container-main"><div id="content" class="content" role="main"><div class="main-outer-wrapper "><div class="bit_row"><div class="twelve columns no-sidebar-content "><div class="bit_row"><div class="content-wrapper twelve columns "><section data-fixheight="" class="qfy-row-1-59a7c0a611f02205201 section bothfull section-text-no-shadow section-inner-no-shadow section-normal" id="bit_iebxo" style='margin-bottom:0;border-radius:0px;color:#000000;'><style>@media only screen and (min-width: 992px) {section.section.qfy-row-1-59a7c0a611f02205201 {padding-left: 0;padding-right: 0;padding-top: 0;padding-bottom: 0;margin-top: 0;min-height: 1px;}}@media only screen and (max-width: 992px) {.bit-html section.section.qfy-row-1-59a7c0a611f02205201 {padding-left: 15px;padding-right: 15px;padding-top: 0;padding-bottom: 0;margin-top: 0;min-height: 1px;}}</style><div class="section-background-overlay background-overlay grid-overlay-0 " style="background-color: #e2e2e2;"></div><div class="container"><div class="row wpb_row"><div data-animaleinbegin="bottom-in-view" data-animalename="qfyfadeInUp" data-delay="" class=" qfy-column-1-59a7c0a61220f49158 qfy-column-inner vc_span12 text-default small-screen-undefined fullrow" data-dw="1/1" data-fixheight=""><div style=";position:relative;;" class="column_inner "><div class=" background-overlay grid-overlay-" style="background-color:transparent;width:100%;"></div><div class="column_containter" style="z-index:3;position:relative;"></div></div></div><style>@media only screen and (min-width: 992px) {.qfy-column-1-59a7c0a61220f49158 > .column_inner {padding-left: 0;padding-right: 0;padding-top: 0;padding-bottom: 0;}.wpb_row .vc_span_class.qfy-column-1-59a7c0a61220f49158 {};}@media only screen and (max-width: 992px) {.qfy-column-1-59a7c0a61220f49158 > .column_inner {margin: 0 auto 0 !important;padding-left: 0;padding-right: 0;padding-top:;padding-bottom:;}.display_entire .wpb_row .vc_span_class.qfy-column-1-59a7c0a61220f49158 {}.qfy-column-1-59a7c0a61220f49158 > .column_inner > .background-overlay, .qfy-column-1-59a7c0a61220f49158 > .column_inner > .background-media {width: 100% !important;left: 0 !important;right: auto !important;}}</style></div></div></section><section data-fixheight="" class="qfy-row-2-59a7c0a612643221365 section no section-text-no-shadow section-inner-no-shadow section-normal" id="bit_83rih" style='margin-bottom:0;border-radius:0px;color:#666666;'><style>@media only screen and (min-width: 992px) {section.section.qfy-row-2-59a7c0a612643221365 {padding-left: 0;padding-right: 0;padding-top: 0;padding-bottom: 0;margin-top: 0;}section.section.qfy-row-2-59a7c0a612643221365 > .container {max-width: 1280px;margin: 0 auto;}}@media only screen and (max-width: 992px) {.bit-html section.section.qfy-row-2-59a7c0a612643221365 {padding-left: 15px;padding-right: 15px;padding-top: 0;padding-bottom: 0;margin-top: 0;}}</style><div class="section-background-overlay background-overlay grid-overlay-0 " style="background-color: #ffffff;"></div><div class="container"><div class="row wpb_row"><%@ include file="iframe/left.jsp" %><style>@media only screen and (min-width: 992px) {.qfy-column-2-59a7c0a612b45557685 > .column_inner {padding-left: 0;padding-right: 0;padding-top: 20px;padding-bottom: 0;}.wpb_row .vc_span_class.qfy-column-2-59a7c0a612b45557685 {width: 22.501747572815532%;};}@media only screen and (max-width: 992px) {.qfy-column-2-59a7c0a612b45557685 > .column_inner {margin: 0 auto 0 !important;padding-left: 0;padding-right: 0;padding-top: 0;padding-bottom: 0;}.display_entire .wpb_row .vc_span_class.qfy-column-2-59a7c0a612b45557685 {width: 22.501747572815532%;}.qfy-column-2-59a7c0a612b45557685 > .column_inner > .background-overlay, .qfy-column-2-59a7c0a612b45557685 > .column_inner > .background-media {width: 100% !important;left: 0 !important;right: auto !important;}}</style><div data-animaleinbegin="bottom-in-view" data-animalename="qfyfadeInUp" data-delay="" class=" qfy-column-3-59a7c0a613dc5780320 qfy-column-inner vc_span_class vc_span9 text-default small-screen-default notfullrow" data-dw="3/4" data-fixheight=""><div style=";position:relative;;" class="column_inner "><div class=" background-overlay grid-overlay-" style="background-color:transparent;width:100%;"></div><div class="column_containter" style="z-index:3;position:relative;"><div id="" data-loading="" data-loading-w="" data-open="" data-post="post" data-cate="50" m-padding="0px 0px 0px 0px" p-padding="0 0 0 0" css_animation_delay="0" qfyuuid="qfy_posts_grid_ytk5x" class="qfy-element UUID-POSTS-59a7c0a617b55120475 wpb_teaser_grid wpb_content_element wpb_grid columns_count_1 columns_count_1 wpb_teaser_grid_post " style="margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;border-radius:0px;"><style>.UUID-POSTS-59a7c0a617b55120475 li:hover .post-title > i.glyphicon {color: #cccccc !important;}.UUID-POSTS-59a7c0a617b55120475 li:hover .subtitle {color: #cccccc !important;}.UUID-POSTS-59a7c0a617b55120475 li:hover .vc_read_more {}@media only screen and (max-width: 760px) {.UUID-POSTS-59a7c0a617b55120475 .post_blog .blog-media {width: 100% !important;}.thumbnail_text-59a7c0a617b0e911 .head {font-size: 16px !important;}.thumbnail_text-59a7c0a617b0e911 .content {font-size: 16px !important;}}.UUID-POSTS-59a7c0a617b55120475 .qfy_item_post .price_warp .amount, .UUID-POSTS-59a7c0a617b55120475 .qfy_item_post .price_warp del {color: #cccccc;font-size: 12px;}.UUID-POSTS-59a7c0a617b55120475 .qfy_item_post .price_warp ins .amount {color: #cccccc;font-size: 12px;}.UUID-POSTS-59a7c0a617b55120475 .qfy_item_post .price_warp {padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;}.UUID-POSTS-59a7c0a617b55120475 .qfy_item_post:hover .price_warp .amount, .UUID-POSTS-59a7c0a617b55120475 .qfy_item_post:hover .price_warp del {color: #cccccc !important;}.UUID-POSTS-59a7c0a617b55120475 .qfy_item_post:hover .price_warp ins .amount {color: #cccccc !important;}.UUID-POSTS-59a7c0a617b55120475 li:hover * {transition: all .6s ease;}.UUID-POSTS-59a7c0a617b55120475 li * {transition: all .6s ease;}</style><div class="wpb_wrapper"><div class="teaser_grid_container noanimale" style=';clear:both;' data-type="post" data-cate="50" data-pcate=""><ul style="min-height:60px;" class="wpb_thumbnails wpb_thumbnails-fluid vc_clearfix post_blog " data-layout-mode="fitRows"><%if(!AllgoodsList.isEmpty()){for(int alln1=0;alln1<AllgoodsList.size();alln1++){List allnew=(List)AllgoodsList.get(alln1);%><li data-postid="11304" data-animaleinbegin="bottom-in-view" data-animalename="qfyfadeInUp" data-delay="0" class=" isotope-item qfy_item_post vc_span12 grid-cat-48 grid-cat-1 grid-cat-50" style='max-width:99.8%;margin-bottom:15px;padding-bottom:15px;border-bottom:1px solid #e5e5e5;'><div class='itembody' style=""><div class="blog-content wf-td" style="display:block;word-break:break-all"><div class="post-title" style='font-weight:normal;color:#53b1c4;line-height:20px; vertical-align: top; '><a data-title="true" style="color:#53b1c4;font-size:20px;font-family:微软雅黑;line-height:20px" href="<%=path%>/goodsinfo.jsp?id=<%=allnew.get(0).toString()%>" class="bitImageAhover link_title" ><%=allnew.get(1).toString()%></a></div></div></div></li><div class="wf-mobile-hidden" style="clear:both"></div><%}} %></ul></div></div><div class="clear"></div></div></div></div></div><style>@media only screen and (min-width: 992px) {.qfy-column-3-59a7c0a613dc5780320 > .column_inner {padding-left: 21px;padding-right: 96px;padding-top: 34px;padding-bottom: 0;}.wpb_row .vc_span_class.qfy-column-3-59a7c0a613dc5780320 {width: 77.4%;};}@media only screen and (max-width: 992px) {.qfy-column-3-59a7c0a613dc5780320 > .column_inner {margin: 0 auto 0 !important;padding-left: 0;padding-right: 0;padding-top: 34px;padding-bottom:;}.display_entire .wpb_row .vc_span_class.qfy-column-3-59a7c0a613dc5780320 {width: 77.4%;}.qfy-column-3-59a7c0a613dc5780320 > .column_inner > .background-overlay, .qfy-column-3-59a7c0a613dc5780320 > .column_inner > .background-media {width: 100% !important;left: 0 !important;right: auto !important;}}</style><div class="wf-mobile-hidden qfy-clumn-clear" style="clear:both;"></div></div></div></section></div><div class="clear"></div></div></div></div><!-- END .page-wrapper --><div class="clear"></div></div><div class="clear"></div></div></div><!-- .wf-container --></div><!-- .wf-wrap --></div><!-- #main --><!-- !Bottom-bar --><%@ include file="iframe/foot.jsp" %><!-- #bottom-bar --></div>
<a href="#" class="scroll-top "></a>
</body>
</html>