springMvc+Mybatis整合

本项目采用Spring MVC框架,整合MyBatis实现商品信息管理。包括商品的增删查改等功能,并详细介绍了项目结构、配置文件及核心代码。

项目结构



1、导入相关的jar包

ant-1.9.6.jar

ant-launcher-1.9.6.jar

asm-5.2.jar

aspectjweaver-1.8.11.jar

cglib-3.2.5.jar

commons-dbcp-1.4.jar

commons-fileupload-1.3.1.jar

commons-io-2.5.jar

commons-logging-1.1.3.jar

commons-logging-1.2.jar

commons-pool-1.6.jar

jackson-core-asl-1.9.2.jar

jackson-mapper-asl-1.9.2.jar

javassist-3.22.0-CR2.jar

json-lib-2.3-jdk15.jar

jstl-1.2.jar

log4j-1.2.17.jar

log4j-api-2.3.jar

log4j-core-2.3.jar

mybatis-3.4.5.jar

mybatis-spring-1.3.1.jar

mysql-connector-java-5.1.10-bin.jar

ognl-3.1.15.jar

pagehelper-5.1.2.jar

quartz-2.3.0.jar

slf4j-api-1.7.25.jar

slf4j-log4j12-1.7.25.jar

spring-aop-4.3.10.RELEASE.jar

spring-aspects-4.3.10.RELEASE.jar

spring-beans-4.3.10.RELEASE.jar

spring-context-4.3.10.RELEASE.jar

spring-context-support-4.3.10.RELEASE.jar

spring-core-4.3.10.RELEASE.jar

spring-expression-4.3.10.RELEASE.jar

spring-instrument-4.3.10.RELEASE.jar

spring-instrument-tomcat-4.3.10.RELEASE.jar

spring-jdbc-4.3.10.RELEASE.jar

spring-jms-4.3.10.RELEASE.jar

spring-messaging-4.3.10.RELEASE.jar

spring-orm-4.3.10.RELEASE.jar

spring-oxm-4.3.10.RELEASE.jar

spring-test-4.3.10.RELEASE.jar

spring-tx-4.3.10.RELEASE.jar

spring-web-4.3.10.RELEASE.jar

spring-webmvc-4.3.10.RELEASE.jar

spring-webmvc-portlet-4.3.10.RELEASE.jar

spring-websocket-4.3.10.RELEASE.jar


2、配置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_3_0.xsd" id="WebApp_ID" version="3.0">
  <listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <context-param>
  		<param-name>contextConfigLocation</param-name>
		<param-value>
			classpath:config/applicationContext.xml,
		</param-value>
  </context-param>
  
  <servlet>
  	<servlet-name>hello</servlet-name>
  	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  	<init-param>
  		<param-name>contextConfigLocation</param-name>
  		<param-value>classpath:config/hello-servlet.xml</param-value>
  	</init-param>
  	<load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
  	<servlet-name>hello</servlet-name>
  	<url-pattern>/</url-pattern>
  </servlet-mapping>
  
  <filter>  
        <filter-name>encodingFilter</filter-name>  
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
        <init-param>  
            <param-name>encoding</param-name>  
            <param-value>UTF-8</param-value>  
        </init-param>  
    </filter>  
    <filter-mapping>  
        <filter-name>encodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>
</web-app>
2、配置hello-servlet.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.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
        
      <context:component-scan base-package="com.mvn.controller">
      	
      </context:component-scan>
      <mvc:annotation-driven/>
      <!-- 将静态文件指定到某个路径 -->
      <mvc:resources location="/resources/" mapping="/resources/**"/>
      <mvc:resources location="/images/" mapping="/images/**"/>
      <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      	<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
      	<property name="prefix" value="/WEB-INF/jsp/"/>
      	<property name="suffix" value=".jsp"/>
      </bean>
      <!-- 设置multipartResolver才能完成文件上传 -->
      <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
      	<property name="maxUploadSize" value="5000000"/>
      </bean> 
      <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
      </bean> 
</beans>

3.Shop.java类

public class Shop {
	private int id;
	private String name;
	private String img;
	private float price;
	private Date addTime;
	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 getImg() {
		return img;
	}
	public void setImg(String img) {
		this.img = img;
	}
	public float getPrice() {
		return price;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
}

4、ShopDao接口类

public interface ShopDao {
	/**
	 * 根据id查找
	 * @param id
	 * @return
	 */
	public Shop getShopById(String str, int id);
	/**
	 * 添加
	 * @param orderDao
	 * @return
	 */
	public int add(String str,Object ob);
	
	/**
	 * 查找list集合
	 * @return
	 */
	public List<Shop> getAllShop(String str);

}

5、ShopDaoImpl实现类

@Repository("shopDao")
public class ShopDaoImpl implements ShopDao{
	
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSession;

	@Override
	public Shop getShopById(String str, int id) {
		// TODO Auto-generated method stub
		return sqlSession.selectOne(str, id);
	}

	@Override
	public int add(String str, Object ob) {
		// TODO Auto-generated method stub
		return sqlSession.insert(str, ob);
	}

	@Override
	public List<Shop> getAllShop(String str) {
		// TODO Auto-generated method stub
		return sqlSession.selectList(str);
	}

}

6、ShopService接口类

public interface ShopService {
	
	public int addShop(Shop shop);

	public Shop findById(int id);
	
	public List<Shop> getAllShop();
}

7、ShopServiceImpl实现类

@Service
public class ShopServiceImpl implements ShopService{
	
	@Resource(name="shopDao")
	private ShopDao shopDao ;

	@Override
	public int addShop(Shop shop) {
		// TODO Auto-generated method stub
		return shopDao.add("com.mvn.dao.ShopDao.add", shop);
	}

	@Override
	public Shop findById(int id) {
		// TODO Auto-generated method stub
		return shopDao.getShopById("com.mvn.dao.ShopDao.getShopById", id);
	}

	@Override
	public List<Shop> getAllShop() {
		// TODO Auto-generated method stub
		return shopDao.getAllShop("com.mvn.dao.ShopDao.getAllShop");
	}

}

8、ShopController类

@Controller
@RequestMapping("/shop")
public class ShopController {
	
	@Autowired(required=true)
	private ShopService shopService;
	
	@RequestMapping("/shopData")
	public ModelAndView list(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mv=new ModelAndView("shop/shopList");
		List<Shop> shopList=shopService.getAllShop();
		mv.addObject("shopList", shopList);
		return mv;
	}
	@RequestMapping("/addShop")
	public ModelAndView add(){
		ModelAndView mv=new ModelAndView("shop/shopAdd");
		return mv;
	}
	@RequestMapping(value="/saveShop",method=RequestMethod.POST)
	public ModelAndView save(Shop shop,MultipartFile file,HttpServletRequest request) throws Exception{
		ModelAndView mv=new ModelAndView("redirect:/shop/shopData");
		shop.setAddTime(new Date());
		String path=null;
		//原始名称  
        String originalFilename = file.getOriginalFilename();  
        //上传图片  
        if(file!=null && originalFilename!=null && originalFilename.length()>0){
			// 存储图片的路径
			String realPath=request.getSession().getServletContext().getRealPath("/")+"/images";
			// 自定义的文件名称
			path=realPath+"/"+originalFilename;
			// 转存文件到指定的路径
			file.transferTo(new File(path));
			System.out.println("文件成功上传到指定目录下");
        }
        shop.setImg(originalFilename);
		shopService.addShop(shop);
		return mv;
	}

}

9、applicationContext.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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="  
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd  
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd  
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
   <!-- 容器自动扫描IOC组件 -->
   <context:annotation-config/>
   <!-- 启动组件扫描,排除@Controller组件,该组件由SpringMVC配置文件扫描 -->
   <context:component-scan base-package="com.mvn">
   	<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
   </context:component-scan>
   
   <!-- 设置要调度的对象 -->
   <bean id="jobBean" class="com.mvn.util.TimedTask" />
   <!-- 定义调用对象和调用对象的方法 -->
   <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
   		<property name="targetObject" ref="jobBean"/>
   		<property name="targetMethod" value="execute"/>
   		<!-- 将并发设置为false -->
   		<property name="concurrent" value="false" />
   </bean>
   <!-- 定义触发时间 -->
   <bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
   		<property name="jobDetail" ref="jobDetail" />
   		<!-- 表达式,设置多长时间执行一次 -->
   		<property name="cronExpression" value="0/30 * * * * ?"/>
   </bean>
   <!-- 总管理类如果将lazy-init='false'那么容器启动就会执行调度程序 -->
   <bean id="startQuertz" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
   		<property name="triggers">
   			<list>
   				<!-- 作业调度器,list下可加入其他的调度器 -->
   				<ref bean="doTime"/>
   			</list>
   		</property>
   </bean>
   <!-- 配置数据源 -->
   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>  
        <property name="url" value="jdbc:mysql://localhost/test"/>  
        <property name="username" value="root"/>  
        <property name="password" value="root"/>  
    </bean> 
    <!-- 会话工厂bean SQLSessionFactoryBean -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    	<!-- 数据源 -->
    	<property name="dataSource" ref="dataSource"/>
    	<!-- configLocation属性指定mybatis的核心配置文件 -->
    	<property name="configLocation" value="classpath:config/Configure.xml"/>
    	<!-- mapper扫描 -->
    	<property name="mapperLocations" value="classpath:config/*Mapper.xml"/>
    </bean>
    <!-- sql会话模版 -->
	<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
		<constructor-arg ref="sqlSessionFactory" />
	</bean>
    <!-- 配置事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    	<property name="dataSource" ref="dataSource"/>
    </bean>
    <!-- 配置事务处理面(事务通知) -->  
    <tx:advice id="appAdvice" transaction-manager="transactionManager">  
        <tx:attributes>  
            <!-- 配置事务属性 -->  
            <!-- 默认值: isolation="DEFAULT" timeout="-1" propagation="REQUIRED" read-only="false" -->  
            <tx:method name="insert*" propagation="REQUIRED" />  
            <tx:method name="update*" propagation="REQUIRED" />  
            <tx:method name="delete*" propagation="REQUIRED" />  
            <tx:method name="batch*" propagation="REQUIRED" />  
            <tx:method name="read*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="get*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="count*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="find*" propagation="REQUIRED" read-only="true" />  
            <tx:method name="*" read-only="true" />  
        </tx:attributes>  
    </tx:advice>  
    <!-- 配置AOP事务 -->  
      <aop:config>    
        <!-- 配置事务切点 -->  
          <aop:pointcut expression="execution(* com.mvn.service.*Service.*(..))"    
                       id="appPoint" />   
        <!-- 结合事务切点与切面 -->  
          <aop:advisor advice-ref="appAdvice" pointcut-ref="appPoint" />    
      </aop:config>    
            
</beans>
10、Configure.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<typeAliases>
		<typeAlias alias="User" type="com.mvn.model.User"/>
		<typeAlias alias="Order" type="com.mvn.model.Order"/>
		<typeAlias alias="Shop" type="com.mvn.model.Shop"/>
	</typeAliases>
</configuration>

11、ShopMapper.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 命名空间应该是对应接口的包名+接口名 -->
<mapper namespace="com.mvn.dao.ShopDao">
	<resultMap type="Shop" id="resultShop">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <result column="img" property="img" />
        <result column="price" property="price" />
        <result column="addTime" property="addTime" />
    </resultMap>
	<!-- id对应接口中的方法,结果类型如没有配置别名则应该使用全名称 -->
	<select id="getAllShop" resultType="Shop">
		select * from `shop`
	</select>
	<select id="getShopById" resultType="Shop">
		select * from `shop` where id=#{id}
	</select>
	<insert id="add">
		insert into `shop`(id,name,img,price,addTime) 
		values(#{id},#{name},#{img},#{price},#{addTime})
	</insert>
	<delete id="delete">
		delete from `shop` where id=#{sid}
	</delete>
</mapper>

12、shopList.jsp页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单商品列表页面</title>
<style type="text/css">
* {
    margin: 0;
    padding: 0;
    font-family: microsoft yahei;
    font-size: 14px;
}

body {
    padding-top: 20px;
}

.main {
    width: 90%;
    margin: 0 auto;
    border: 1px solid #777;
    padding: 20px;
}

.main .title {
    font-size: 20px;
    font-weight: normal;
    border-bottom: 1px solid #ccc;
    margin-bottom: 15px;
    padding-bottom: 5px;
    color: blue;
}

.main .title span {
    display: inline-block;
    font-size: 20px; 
    background : blue;
    color: #fff;
    padding: 0 8px;
    background: blue;
}

a {
    color: blue;
    text-decoration: none;
}

a:hover {
    color: orangered;
}

.tab td, .tab, .tab th {
    border: 1px solid #777;
    border-collapse: collapse;
}

.tab td, .tab th {
    line-height: 26px;
    height: 26px;
    padding-left: 5px;
    text-align:center;
}

.abtn {
    display: inline-block;
    height: 20px;
    line-height: 20px;
    background: blue;
    color: #fff;
    padding: 0 5px;
}
.btn {
    height: 20px;
    line-height: 20px;
    background: blue;
    color: #fff;
    padding: 0 8px;
    border:0;
}

.abtn:hover,.btn:hover{
    background: orangered;
    color: #fff;
}
p{
    padding:5px 0;
}
</style>
</head>
<body>
	<div class="main">
		<h2 class="title">
			<span>商品列表</span>
		</h2>
		<form action="deletes" method="post">
			<table border="1" width="100%" class="tab">
				<tr>
					<th><input type="checkbox" id="chbAll"></th>
					<th>id</th>
					<th>商品名称</th>
					<th>商品图片</th>
					<th>商品价格</th>
					<th>添加时间</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${shopList}" var="sp">
					<tr>
						<th><input type="checkbox" name="ids" value="${sp.id}"></th>
						<td>${sp.id}</td>
						<td>${sp.name}</td>
						<td><img src="http://localhost:8080/springMvc/images/${sp.img}" style="width:100px;height:100px"/></td>
						<td>${sp.price}</td>
						
						<td><fmt:formatDate value="${sp.addTime}" type="date" pattern="yyyy-MM-dd"/></td>
						
						<td>
						<a href="delete/${sp.id}" class="abtn">删除</a> 
						<a href="update/${sp.id}" class="abtn">编辑</a>
						</td>
					</tr>
				</c:forEach>
			</table>
			<p>
				<a href="addShop" class="abtn">添加</a>
				<input type="submit" value="删除选择项" class="btn"/>
			</p>
		</form>
	</div>
</body>
</html>

13、shopAdd.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加商品</title>
<style type="text/css">
	* {
    margin: 0;
    padding: 0;
    font-family: microsoft yahei;
    font-size: 14px;
}

body {
    padding-top: 20px;
}

.main {
    width: 90%;
    margin: 0 auto;
    border: 1px solid #777;
    padding: 20px;
}

.main .title {
    font-size: 20px;
    font-weight: normal;
    border-bottom: 1px solid #ccc;
    margin-bottom: 15px;
    padding-bottom: 5px;
    color: blue;
}

.main .title span {
    display: inline-block;
    font-size: 20px; 
    background : blue;
    color: #fff;
    padding: 0 8px;
    background: blue;
}

a {
    color: blue;
    text-decoration: none;
}

a:hover {
    color: orangered;
}

.tab td, .tab, .tab th {
    border: 1px solid #777;
    border-collapse: collapse;
}

.tab td, .tab th {
    line-height: 26px;
    height: 26px;
    padding-left: 5px;
}

.abtn {
    display: inline-block;
    height: 20px;
    line-height: 20px;
    background: blue;
    color: #fff;
    padding: 0 5px;
}
.btn {
    height: 20px;
    line-height: 20px;
    background: blue;
    color: #fff;
    padding: 0 8px;
    border:0;
}

.abtn:hover,.btn:hover{
    background: orangered;
    color: #fff;
}
p{
    padding:5px 0;
}
fieldset{
        border: 1px solid #ccc;
        padding:5px 10px;
}
fieldset legend{
    margin-left:10px;
    font-size:16px;
}
</style>
</head>

<body>
	<div class="main">
		<h2 class="title">
			<span>新增商品</span>
		</h2>
		<form action="saveShop" method="post" enctype="multipart/form-data">
			<fieldset>
				<legend>商品</legend>
				<p>
					<label for="title">商品名称:</label> <input type="text" id="name"
						name="name" value="${shop.name}" />
				</p>
				<p>
					<label for="title">商品图片:</label> <input type="file" id="img"
					name="file" value="${shop.img }"/>
				</p>
				<p>
					<label for="title">商品价格:</label> <input type="text" id="price"
						name="price" value="${user.price}" />
				</p>
				<p>
					<input type="submit" value="保存" class="btn">
				</p>
			</fieldset>
		</form>
	</div>
</body>
</html>
列表页面:



添加页面:


以上代码只展示了部分,源码下载地址:http://download.csdn.net/download/u011936251/10123851


源码下载地址: https://pan.quark.cn/s/a4b39357ea24 在电磁模拟技术中,CST(Computer Simulation Technology)是一种被广泛采纳的软件工具,它主要用于电磁场、微波、天线以及射频系统的设计工作。本资料将详细分析CST软件中离散端口的具体配置方法,这些方法对于提升仿真结果的精确度和专业水准具有决定性作用。离散端口在CST软件中扮演着模拟信号输入或输出的重要角色,它们构成了仿真模型不可或缺的部分。在配置离散端口时,一个核心的原则是保证端口的方向与网格线保持一致,这是因为这样做能够有效降低计算过程中产生的误差,并确保仿真数据的有效性。如果未能遵循这一指导原则,可能会引发未知的计算问题,进而导致仿真结果失去可靠性。 在CST软件中配置离散端口,通常需要借助“Pick Points”这一功能。通过选择“Pick Edge Center”选项,端口将被设定在模型边缘的中心位置上。然而,这种做法并不总是能够确保端口与网格线保持平行。在某些特定情形下,模型的几何构造可能不允许直接选取一个与网格线平行的边作为端口的安装位置。 为了克服这一挑战,可以采用多种不同的策略。如果模型本身已经包含一条与馈电口平行的边,那么可以直接利用这条边来建立端口,此时CST软件会自动调整端口使其与网格线对齐。另一种可选的方法是,当模型不具备现成的平行边时,用户可以手动构建一个几何结构,比如一个立方体,并使其边缘与馈电口平行。通过这种方式,新建立的几何结构的边缘就可以作为端口的位置,从而确保端口与网格线的平行关系。 在实施上述操作时,必须关注端口尺寸的合理性和物理意义的一致性。端口的尺寸应当依据实际天线馈电部分的尺寸进行适当调整,过大的端口或...
代码下载链接: https://pan.quark.cn/s/a4b39357ea24 【使用TensorFlow进行图像识别】 图像识别作为计算机视觉领域的关键任务之一,其核心在于通过算法解析和理解图像所包含的信息。在此资源中,我们将集中探讨如何借助功能强大的深度学习框架TensorFlow来执行手写数字识别。手写数字识别构成了众多实际应用的基础,例如自动支票处理、光学字符识别(OCR)等场景。 TensorFlow是由Google创建的一个开源库,它主要用于数值运算和机器学习,尤其在深度学习方面表现卓越。其核心优势在于可以构建并训练复杂的神经网络架构,并且在多种硬件环境中实现高效执行,涵盖CPU和GPU平台。 在此实践项目中,我们将运用TensorFlow来构建一个卷积神经网络(CNN)模型,这种架构是处理图像数据的理想选择。CNNs通过模仿人脑视觉皮层的运作机制,能够自主地提取图像中的关键特征,进而达成识别目标。在手写数字识别的特定情境下,这些特征可能涉及笔画的几何形态、走向以及相互间的连接模式。 对于CNN的基础结构,我们需要具备相应的认知,其通常由卷积层、池化层、全连接层以及激活函数等部分组成。卷积层借助滤波器(亦称卷积核)对图像进行扫描,以捕捉局部特征;池化层则用于降低数据维度,同时保留核心信息;全连接层将特征向量映射至各类别的概率分布;而激活函数如ReLU则通过引入非线性元素,使模型能够学习更为复杂的模式。 在此案例中,建议采用MNIST数据集,这是一个广泛用于手写数字识别的标准测试集。该数据集包含60,000个训练样本和10,000个测试样本,每个样本均为28x28像素的灰度图像,代表0到9这十个数字中的某一个。为了训练模型,必须首先加载数据,并...
代码转载自:https://pan.quark.cn/s/a4b39357ea24 《建伍TM-481车台中文使用说明书》提供了详尽的说明 建伍TM-481是一款专门为车载通信目的而研发的专业对讲机,其在无线电通信领域具有普遍的应用。该设备凭借其优异的性能、可靠的品质以及便捷的操作,赢得了业余无线电发烧友和专业使用者的青睐。接下来我们将深入分析TM-481的核心特性与操作方法。 一、产品概述 建伍TM-481车台具备紧凑的结构,能够适应各种车辆安装条件。它拥有宽频带覆盖功能,支持多种通信方式,包括模拟FM、数字FDMA等,能够应对不同环境下的通信需求。同时,TM-481还拥有出色的抗干扰性能,保障在复杂的电磁环境下也能进行稳定通信。 二、功能特性 1. 多频段支持:TM-481覆盖了多个UHF频段,可以实现VHF和UHF之间的转换,适合不同的通信范围。 2. 数字与模拟兼容性:除了常规的模拟通信,TM-481还支持数字通信方式,提供更清晰的语音传输效果和更优化的信道利用效率。 3. 高效的扫描功能:内置多种扫描模式,例如频率扫描、记忆扫描等,能够迅速定位可用的频道。 4. 自动电平控制(ALC):保证发射功率的稳定,避免过强信号对其他用户造成干扰。 5. 紧急报警系统:配备紧急报警装置,可以在紧急情况下迅速向其他用户发出警示。 6. 高亮度显示屏:采用大尺寸屏幕显示,即使在强光照射下也能清楚查看信息。 三、操作指南 1. 安装与连接:将TM-481固定在车内合适的部位,连接电源线、天线及麦克风,确保所有连接点正确且牢固。 2. 频道设置:通过菜单界面或直接按键设定所需的通信频道,可以保存在内存中以便随时调用。 3. 通信模式选择:依据需求在模拟和数字模式之间...
代码转载自:https://pan.quark.cn/s/dfe8a2c7bf25 Qt被视为一个跨平台的C++图形用户界面应用程序框架,它为应用程序开发者提供了构建艺术级图形用户界面所需的所有功能。Qt最初是在1991年由奇趣科技创建的,随后在1996年进入商业化运作。得益于其完全面向对象的特性,Qt展现出高度的扩展性,并且支持真正的组件化编程。当前,Qt能够支持多种操作系统平台,涵盖了Windows系列、UNIX/X11系列(包括Linux、SunSolaris等)、Macintosh以及嵌入式平台。依据授权模式的不同,Qt被划分为商业版和开源版。商业版为商业软件的开发提供了环境支持,同时包含了免费升级服务和技术支持,而开源版则是在GNU通用公共许可证下提供的免费开放源码软件。 在Qt的开发与实例部分,阐述了如何安装Qt及其开发环境,并通过一个计算圆面积的实例来演示Qt的开发流程,以此帮助读者对GUI应用程序开发形成初步认识。Qt的跨平台特性允许开发者在多种操作系统上编写和构建应用程序,而Qt Creator是Qt提供的集成开发环境(IDE),它整合了代码编辑器、调试器、分析工具等多种开发工具。 Qt还引入了信号和槽机制,这是一种用于事件管理的机制,使得开发者能够通过信号(Signal)和槽(Slot)来关联对象,一旦信号被触发,相应的槽函数便会执行。这种机制在开发图形用户界面程序时显得尤为重要,比如,当用户点击一个按钮时可以触发一个信号,该信号可以连接到一个槽函数来执行点击后的相应操作。 Qt Creator的界面得到了详尽的描述,涵盖了各种常用的窗口和面板。通过本书提供的源代码,读者可以开展实践操作,从而更深入地理解Qt的应用程序开发流程。源代码中包...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值