完整数据库和完善的后台管理功能的新桃彩源码
2018-03-10 11:23
676 查看
1、SpringMVC 概述
(1)、 MVC:Model-View-ControlControl 层属于框架性质,完成的主要工作是:封装 web 请求为一个数据对象、调用业务逻辑层来处理数据对象、返回处理数据结果及相应的视图给客户端。(2)、什么是 SpringMVCSpring mvc 和 Struts2 都属于表现层的框架,是 Spring 框架的一部分,Spring 框架的 Control 层的核心是 DispatcherServlet,它的作用是将请求分发给不同的后端处理器。Spring 的 Control 层框架使用了后端控制器来映射处理器和视图解析器来共同完成 Control 层框架的主要工作。并且 spring 的 Control 层框架还真正地把业务层处理的数据结果和相应的视图拼成一个对象,即 ModelAndView 对象。SpringMVC 本身就是 Spring 的子项目,对 Spring 兼容性很好,因此也不需要做过多的配置。(3)SpringMVC 框架处理流程2、SpringMVC 入门实例
(1)、创建 web 项目,导入所需要的 jar 包,如图下图所示:(2)、创建 SpringMVC 的核心配置文件,具体配置如下:
springmvc.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 扫描@Controler @Service --> <context:component-scan base-package="com.springmvc"/> <!-- 处理器映射器 --> <!-- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/> --> <!-- 处理器适配器 --> <!-- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/> --> <!-- 注解驱动 --> <mvc:annotation-driven/> <!-- 视图解释器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> </beans>(3)、配置 SpringMVC 的前端控制器 DispatcherServlet,具体配置如下:
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>SpringmvcProject</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.action</url-pattern> </servlet-mapping> </web-app>(4)、在 /WEB-INF/ 目录下新建 jsp 目录,新建 jsp 文件,具体代码如下:
itemList.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>查询商品列表</title> </head> <body> <form action="${pageContext.request.contextPath }/item/queryitem.action" method="post"> <p></p> 商品列表: <p></p> <table width="100%" border=1> <tr> <td>商品名称</td> <td>商品价格</td> <td>生产日期</td> <td>商品描述</td> </tr> <c:forEach items="${itemList }" var="item"> <tr> <td>${item.name }</td> <td>${item.price }</td> <td><fmt:formatDate value="${item.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/></td> <td>${item.detail }</td> </tr> </c:forEach> </table> </form> </body> </html>(5)、创建 POJO 类,具体代码如下:
Items.java
package com.springmvc.pojo; import java.util.Date; public class Items { public Items(Integer id, String name, Float price, Date createtime, String detail) { super(); this.id = id; this.name = name; this.price = price; this.createtime = createtime; this.detail = detail; } private Integer id; private String name; private Float price; private String pic; private Date createtime; private String detail; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name == null ? null : name.trim(); } public Float getPrice() { return price; } public void setPrice(Float price) { this.price = price; } public String getPic() { return pic; } public void setPic(String pic) { this.pic = pic == null ? null : pic.trim(); } public Date getCreatetime() { return createtime; } public void setCreatetime(Date createtime) { this.createtime = createtime; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail == null ? null : detail.trim(); } }(6)、创建 Controller 类,具体代码如下:
ItemController.java
package com.springmvc.controller; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.springmvc.pojo.Items; /** * 商品管理 * * @author lx * */ @Controller public class ItemController { @RequestMapping(value = "/itemlist.action") public ModelAndView itemList(){ // 创建页面需要显示的商品数据 List<Items> list = new ArrayList<Items>(); list.add(new Items(1, "1华为 荣耀8", 2399f, new Date(), "质量好!1")); list.add(new Items(2, "2华为 荣耀8", 2399f, new Date(), "质量好!2")); list.add(new Items(3, "3华为 荣耀8", 2399f, new Date(), "质量好!3")); list.add(new Items(4, "4华为 荣耀8", 2399f, new Date(), "质量好!4")); list.add(new Items(5, "5华为 荣耀8", 2399f, new Date(), "质量好!5")); list.add(new Items(6, "6华为 荣耀8", 2399f, new Date(), "质量好!6")); ModelAndView mav = new ModelAndView(); //数据 mav.addObject("itemList", list); mav.setViewName("itemList"); return mav; } }
完整数据库和完善的后台管理功能的新桃彩源码【大神源码论坛】super-mans.com 信大神,非凡人~~~
相关文章推荐
- H5 牛牛源码 微信牛牛 带后台控制 最新班带管理功能 大番薯
- [原创]ExtAspNet新春贺岁版 - 文件上传控件、复选框列表控件、完善布局管理、表格的行扩展列、完整的100多个中文示例、30多处BUG修正与功能增强、《ExtAspNet秘密花园》系列文章
- 基于Struts+Hibernate开发的后台管理,功能包含完善的权限管理和信息发布功能
- django不用在数据库中创建新的user表而使用它的后台管理功能
- 【转】[原创]ExtAspNet新春贺岁版 - 文件上传控件、复选框列表控件、完善布局管理、表格的行扩展列、完整的100多个中文示例、30多处BUG修正与功能增强、《ExtAspNet秘密花园》系列文章
- 源码编译LAMP架构,phpMyadmin管理数据库,增加xcache加速功能,通过ab测试效果。
- JS实现可编辑的后台管理菜单功能【附demo源码下载】
- Extjs4.2进阶--完整前后台交互带数据库(带源码)
- ExtAspNet新春贺岁版 - 文件上传控件、复选框列表控件、完善布局管理、表格的行扩展列、完整的100多个中文示例、30多处BUG修正与功能增强、《ExtAspNet秘密花园》系列文章
- Extjs4.2进阶--完整前后台交互带数据库(带源码)
- [原创]ExtAspNet新春贺岁版 - 文件上传控件、复选框列表控件、完善布局管理、表格的行扩展列、完整的100多个中文示例、30多处BUG修正与功能增强、《ExtAspNet秘密花园》系列文章
- 源码-Oracle数据库管理-第十章-数据表操作-Part 1(插入数据)
- 【官方文档】《暗黑世界GM管理后台系统》部署+功能说明
- 从前端到后台,开发一个完整功能的小程序
- 明日网全功能超级文件上传管理系统 V1.0 源码发布
- SAP R3 用系统自带的功能查看后台数据库数据 SE16
- SQLite数据库创建、升级数据库、事务处理、添加、更新、删除、查询管理操作类完整代码
- dhtmlxCombo(select非数据库取值),导出excel功能,利用form表单传值getActualValue()到后台判断
- 简单开发的android阅读器源码,包含了读取数据库和文件流处理功能
- 一步一步使用Ext JS MVC与Asp.Net MVC 3开发简单的CMS后台管理系统之完成登录功能