今天给大家演示的是一款jsp+servlet+mysql实现的二手物品在线商城系统,其本质是在线商城,但是鉴于很多童鞋基础比较薄弱,不会修改,因此我修改成了二手物品商城,也附上了基本的修改版权信息和导航条的教程,系统实现了商城的基本功能,如分类展示商品信息、搜索商品信息、用户注册登录、添加商品到购物车、提交订单、个人中心查看订单、留言板留言等,管理员登录后台后可以查看管理用户信息、商品分类信息、商品信息、新闻信息、留言信息、订单信息等。
代码已经上传github,下载地址 https://github.com/21503882/used
1.包含源程序,数据库脚本。代码和数据库脚本都有详细注释。
2.课题设计仅供参考学习使用,可以在此基础上进行扩展完善
开发环境:
Eclipse ,MYSQL,JDK1.8,Tomcat 7
涉及技术点:
MVC模式、SpringMvc、Mybatis、Spring、bootstrap、HTML、JavaScript、CSS、JQUERY、log4j、Ajax、maven等
系统采用Mybatis框架实现ORM对象关系映射,前台JSP实现,后台springMvc映射,使用Spring框架进行整合。适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat7,JDK版本1.8. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离
主要功能:
package com.tuqi;
import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* Created by xingxuan on 17/2/22.
*/
@Slf4j
@Configuration
@MapperScan(value = {"com.tuqi.mapper", "com.tuqi.mapper.ext"})
public class MyBatisConfiguration {
@Value("${spring.datasource.url}")
private String dbUrl;
@Value("${spring.datasource.username}")
private String username;
@Value("${spring.datasource.password}")
private String password;
@Value("${spring.datasource.driverClassName}")
private String driverClassName;
@Value("${spring.datasource.initialSize}")
private int initialSize;
@Value("${spring.datasource.minIdle}")
private int minIdle;
@Value("${spring.datasource.maxActive}")
private int maxActive;
@Value("${spring.datasource.maxWait}")
private int maxWait;
@Value("${spring.datasource.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis;
@Value("${spring.datasource.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis;
@Value("${spring.datasource.validationQuery}")
private String validationQuery;
@Value("${spring.datasource.testWhileIdle}")
private boolean testWhileIdle;
@Value("${spring.datasource.testOnBorrow}")
private boolean testOnBorrow;
@Value("${spring.datasource.testOnReturn}")
private boolean testOnReturn;
@Value("${spring.datasource.poolPreparedStatements}")
private boolean poolPreparedStatements;
@Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize}")
private int maxPoolPreparedStatementPerConnectionSize;
@Value("${spring.datasource.filters}")
private String filters;
@Value("${spring.datasource.connectionProperties}")
private String connectionProperties;
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
//configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
log.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath*:/mapper/**/*.xml"));
return sqlSessionFactoryBean.getObject();
}
@Bean
public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
}
package com.tuqi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TuqiAllApplication {
public static void main(String[] args) {
SpringApplication.run(TuqiAllApplication.class, args);
}
}
package com.tuqi.manager.impl;
import com.tuqi.domain.model.UserTabDO;
import com.tuqi.domain.query.UserTabQuery;
import com.tuqi.manager.UserTabManager;
import com.tuqi.mapper.ext.UserTabExtMapper;
import com.tuqi.mybatisgenerate.query.PageResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* Manager for UserTab.
*/
@Component
public class UserTabManagerImpl implements UserTabManager{
private static final Logger log = LoggerFactory.getLogger(UserTabManagerImpl.class);
@Autowired
protected UserTabExtMapper userTabExtMapper;
/**
* query count by query condition.
*/
@Override
public int countByQuery(UserTabQuery query){
return userTabExtMapper.countByQuery(query);
}
/**
* delete by query condition.
*/
@Override
public int deleteByQuery(UserTabQuery query){
return userTabExtMapper.deleteByQuery(query);
}
/**
* delete by primary key.
*/
@Override
public int deleteByPrimaryKey(UserTabDO record){
return userTabExtMapper.deleteByPrimaryKey(record);
}
/**
* insert selective.
*/
@Override
public long insertSelective(UserTabDO record){
return userTabExtMapper.insertSelective(record);
}
/**
* select by query condition.
*/
@Override
public List
return userTabExtMapper.selectByQuery(query);
}
/**
* select by query condition with page.
*/
@Override
public PageResult
PageResult
result.setPageSize(query.getPageSize());
result.setPageNo(query.getPageNo());
result.setTotalCount(this.countByQuery(query));
result.setPageData(this.selectByQuery(query));
return result;
}
/**
* select by primary key.
*/
@Override
public UserTabDO selectByPrimaryKey(Long id){
return userTabExtMapper.selectByPrimaryKey(id);
}
/**
* update by query condition selective.
*/
@Override
public int updateByQuerySelective( UserTabDO record, UserTabQuery query){
return userTabExtMapper.updateByQuerySelective(record, query);
}
/**
* update by query condition.
*/
@Override
public int updateByQuery( UserTabDO record, UserTabQuery query){
return userTabExtMapper.updateByQuery(record, query);
}
/**
* update by primary key selective.
*/
@Override
public int updateByPrimaryKeySelective(UserTabDO record){
return userTabExtMapper.updateByPrimaryKeySelective(record);
}