查询个人信息和数据库更新

master
zxy19971014 6 years ago
parent 1942cd395a
commit d6b06dfd04

@ -13,7 +13,7 @@
"compileType": "miniprogram",
"libVersion": "2.4.0",
"appid": "wxb280d1925541c356",
"projectname": "%E7%9C%9F%E9%A6%9913",
"projectname": "33",
"debugOptions": {
"hidedInDevtools": []
},

@ -14,33 +14,40 @@
<!-- Spring -->
<spring.version>4.3.10.RELEASE</spring.version>
</properties>
<dependencies>
<!-- mysql数据库驱动类 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.44</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- 导入MyBatis生成器 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<!-- mysql数据库驱动类 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
<!-- Spring -->
<!-- 1)包含Spring 框架基本的核心工具类。Spring 其它组件要都要使用到这个包里的类,
是其它组件的基本核心 -->
<!-- 导入MyBatis生成器 -->
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<!-- Spring -->
<!-- 1)包含Spring 框架基本的核心工具类。Spring 其它组件要都要使用到这个包里的类, 是其它组件的基本核心 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
@ -92,8 +99,7 @@
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- DAO: MyBatis -->
<!-- DAO: MyBatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
@ -104,6 +110,7 @@
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<!-- 连接技术 -->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
@ -114,19 +121,23 @@
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- 单元测试 -->
<!-- https://mvnrepository.com/artifact/junit/junit -->
<!-- Servlet web -->
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>booksService</finalName>
<plugins><!--插件-->
<!-- 配置JDK插件 -->
<plugins>
<!-- 配置JDK插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -137,18 +148,17 @@
<skip>true</skip>
</configuration>
</plugin>
<!-- 配置MyBatis生成器插件 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<!--配置文件的路径 -->
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<!--配置文件的路径 -->
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
<finalName>zxbook</finalName>
</build>
</project>

@ -1,32 +1,51 @@
package controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.Gson;
import domain.yhPO;
import service.yhService;
@Controller
public class yhController {
@Autowired@Qualifier("yhServiceImpl")
private yhService yhService;
@RequestMapping("/search")
public String search(Model model,String s_id){
yhPO yhPO=yhService.search(s_id);
model.addAttribute("s_id", yhPO.getS_id());
model.addAttribute("s_name", yhPO.getS_name());
model.addAttribute("s_password", yhPO.getS_password());
@RequestMapping("find2")
public void find1(String search,HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html;charset=utf-8");
/* 设置响应头允许ajax跨域访问 */
response.setHeader("Access-Control-Allow-Origin", "*");
/* 星号表示所有的异域请求都可以接受, */
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
yhPO yhPO=this.yhService.FindBysname(search);
if(yhPO!=null) {
String ss = new Gson().toJson(yhPO);
System.out.println(ss);
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(ss);
out.flush();
out.close();
}
else
{
System.out.println("查询失败");
Writer out = response.getWriter();
out.write("zhaobudao");
out.flush();
}
}
@RequestMapping("/update")
public String update(yhPO yhPO){
yhService.update(yhPO);
}
}

@ -8,7 +8,7 @@ import domain.yhPO;
@Repository("yhMapperDao")
public interface yhMapperDao {
public yhPO search(String s_id);
public yhPO FindBysname(String search );
public void update(yhPO yhPO);

@ -6,7 +6,7 @@ import domain.yhPO;
public interface yhService {
public yhPO search(String bs_id);
public yhPO FindBysname(String search );
public void update(yhPO yhpo);

@ -5,23 +5,20 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import domain.yhPO;
import mapperDAO.yhMapperDao;
import service.yhService;
import mapperDAO.yhMapperDao;
@Component("yhServiceImpl")
public class yhServiceImpl implements yhService{
@Autowired@Qualifier("yhMapperDao")
private yhMapperDao yhMapperDao;
public yhPO search(String s_id) {
return this.yhMapperDao.search(s_id);
private yhMapperDao yhMapperDAO;
public yhPO FindBysname(String search) {
// TODO Auto-generated method stub
return this.yhMapperDAO.FindBysname(search);
}
public void update(yhPO yhpo) {
// TODO Auto-generated method stub
yhMapperDao.update(yhpo);
}
@ -29,4 +26,5 @@ public class yhServiceImpl implements yhService{
}

@ -6,7 +6,7 @@
<result column="s_password" jdbcType="VARCHAR" property="s_password" />
<result column="s_name" jdbcType="VARCHAR" property="s_name" />
</resultMap>
<select id="search" resultMap="yhMap" parameterType="String">
<select id="FindBysname" resultMap="yhMap" parameterType="String">
SELECT
student.s_id,
student.s_name,
@ -14,7 +14,7 @@
FROM
student
WHERE
student.s_id=#{s_id}
student.s_id=#{search}
</select>
<select id="update" parameterType="domain.yhPO">

@ -1,7 +1,20 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<display-name>Archetype Created Web Application</display-name>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

@ -6,7 +6,7 @@
<result column="s_password" jdbcType="VARCHAR" property="s_password" />
<result column="s_name" jdbcType="VARCHAR" property="s_name" />
</resultMap>
<select id="search" resultMap="yhMap" parameterType="String">
<select id="FindBysname" resultMap="yhMap" parameterType="String">
SELECT
student.s_id,
student.s_name,
@ -14,7 +14,7 @@
FROM
student
WHERE
student.s_id=#{s_id}
student.s_id=#{search}
</select>
<select id="update" parameterType="domain.yhPO">

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Sat Jan 12 16:17:25 CST 2019
#Mon Jan 14 16:52:07 CST 2019
version=0.0.1-SNAPSHOT
groupId=yonghu
m2e.projectName=yhSearch

@ -14,33 +14,40 @@
<!-- Spring -->
<spring.version>4.3.10.RELEASE</spring.version>
</properties>
<dependencies>
<!-- mysql数据库驱动类 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.44</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- 导入MyBatis生成器 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<!-- mysql数据库驱动类 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
<!-- Spring -->
<!-- 1)包含Spring 框架基本的核心工具类。Spring 其它组件要都要使用到这个包里的类,
是其它组件的基本核心 -->
<!-- 导入MyBatis生成器 -->
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<!-- Spring -->
<!-- 1)包含Spring 框架基本的核心工具类。Spring 其它组件要都要使用到这个包里的类, 是其它组件的基本核心 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
@ -92,8 +99,7 @@
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- DAO: MyBatis -->
<!-- DAO: MyBatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
@ -104,6 +110,7 @@
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<!-- 连接技术 -->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
@ -114,19 +121,23 @@
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- 单元测试 -->
<!-- https://mvnrepository.com/artifact/junit/junit -->
<!-- Servlet web -->
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>booksService</finalName>
<plugins><!--插件-->
<!-- 配置JDK插件 -->
<plugins>
<!-- 配置JDK插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -137,18 +148,17 @@
<skip>true</skip>
</configuration>
</plugin>
<!-- 配置MyBatis生成器插件 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<!--配置文件的路径 -->
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
<!--配置文件的路径 -->
<configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
</configuration>
</plugin>
</plugins>
<finalName>zxbook</finalName>
</build>
</project>

@ -3,14 +3,14 @@ Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50639
Source Host : localhost:3306
Source Host : 127.0.0.1:3306
Source Database : zx
Target Server Type : MYSQL
Target Server Version : 50639
File Encoding : 65001
Date: 2019-01-14 15:20:33
Date: 2019-01-14 17:31:38
*/
SET FOREIGN_KEY_CHECKS=0;
@ -31,7 +31,7 @@ CREATE TABLE `book` (
-- ----------------------------
-- Records of book
-- ----------------------------
INSERT INTO `book` VALUES ('1', '四书五经合集', '古代多人', '20', '文学名著类');
INSERT INTO `book` VALUES ('1', '四书五经合集', '古代多人', '20', '文学名著类');
INSERT INTO `book` VALUES ('10', '《格列佛游记》', '佚名', '18', '文学名著类');
INSERT INTO `book` VALUES ('11', '《洛丽塔》', '佚名', '18', '文学名著类');
INSERT INTO `book` VALUES ('12', '《林徽因传》', '张清平', '16', '文学名著类');

Loading…
Cancel
Save