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

master
zxy19971014 6 years ago
parent 1942cd395a
commit d6b06dfd04

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

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

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

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

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

@ -5,23 +5,20 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import domain.yhPO; import domain.yhPO;
import mapperDAO.yhMapperDao;
import service.yhService; import service.yhService;
import mapperDAO.yhMapperDao;
@Component("yhServiceImpl") @Component("yhServiceImpl")
public class yhServiceImpl implements yhService{ public class yhServiceImpl implements yhService{
@Autowired@Qualifier("yhMapperDao") @Autowired@Qualifier("yhMapperDao")
private yhMapperDao yhMapperDao; private yhMapperDao yhMapperDAO;
public yhPO search(String s_id) {
return this.yhMapperDao.search(s_id);
public yhPO FindBysname(String search) {
// TODO Auto-generated method stub
return this.yhMapperDAO.FindBysname(search);
} }
public void update(yhPO yhpo) { public void update(yhPO yhpo) {
// TODO Auto-generated method stub // 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_password" jdbcType="VARCHAR" property="s_password" />
<result column="s_name" jdbcType="VARCHAR" property="s_name" /> <result column="s_name" jdbcType="VARCHAR" property="s_name" />
</resultMap> </resultMap>
<select id="search" resultMap="yhMap" parameterType="String"> <select id="FindBysname" resultMap="yhMap" parameterType="String">
SELECT SELECT
student.s_id, student.s_id,
student.s_name, student.s_name,
@ -14,7 +14,7 @@
FROM FROM
student student
WHERE WHERE
student.s_id=#{s_id} student.s_id=#{search}
</select> </select>
<select id="update" parameterType="domain.yhPO"> <select id="update" parameterType="domain.yhPO">

@ -1,7 +1,20 @@
<!DOCTYPE web-app PUBLIC <!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app> <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> </web-app>

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

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse #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 version=0.0.1-SNAPSHOT
groupId=yonghu groupId=yonghu
m2e.projectName=yhSearch m2e.projectName=yhSearch

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

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

Loading…
Cancel
Save