1.创建如下mysql脚本

 drop table if exists book_info;

 create table if not exists book_info(
book_id int(10) primary key auto_increment,
book_name varchar(50) not null,
book_author varchar(50) not null,
book_publish varchar(50) not null,
book_page int(10) not null,
book_price double(10,2) not null,
creation_time date not null
); insert into book_info
(book_name,book_author,book_publish,book_page,book_price,creation_time)
values
('Java与模式','闫磊','电子工业出版社',1100,97.00,'2017-01-01'),
('Java核心','(美)Cay S.Horstmann','机械工业出版社',678,333.00,'2017-01-02'),
('Java编程思想','(美)Bruce Exkel','机械工业出版社',590,75.00,'2017-01-03'),
('TCP/IP详解','(美)W.Ricahr Steves','机械工业出版社',205,90.20,'2017-01-04'),
('什么是数学','R.阿朗','复旦大学出版社',521,42.00,'2017-01-05')
; select * from book_info;

book_info

2.创建项目Spring_Mybatis_Exam9

3.导入jar文件,注意:mysql是jar文件版本:mysql-connector-java-5.1.7-bin.jar或更高版本

4.在src下的com.pojo包下创建BookInfo.java

 package com.pojo;
import java.io.Serializable;
public class BookInfo implements Serializable{
private static final long serialVersionUID = 1L;
private Integer book_id ;
private Integer book_page ;
private Double book_price ;
private String book_name ;
private String book_author ;
private String book_publish ;
private String creation_time; public BookInfo() {
} public BookInfo(Integer bookPage, Double bookPrice, String bookName,
String bookAuthor, String bookPublish, String creationTime) {
book_page = bookPage;
book_price = bookPrice;
book_name = bookName;
book_author = bookAuthor;
book_publish = bookPublish;
creation_time = creationTime;
} public BookInfo(Integer bookId, Integer bookPage, Double bookPrice,
String bookName, String bookAuthor, String bookPublish,
String creationTime) {
book_id = bookId;
book_page = bookPage;
book_price = bookPrice;
book_name = bookName;
book_author = bookAuthor;
book_publish = bookPublish;
creation_time = creationTime;
}
public Integer getBook_id() {
return book_id;
}
public void setBook_id(Integer bookId) {
book_id = bookId;
}
public Integer getBook_page() {
return book_page;
}
public void setBook_page(Integer bookPage) {
book_page = bookPage;
}
public Double getBook_price() {
return book_price;
}
public void setBook_price(Double bookPrice) {
book_price = bookPrice;
}
public String getBook_name() {
return book_name;
}
public void setBook_name(String bookName) {
book_name = bookName;
}
public String getBook_author() {
return book_author;
}
public void setBook_author(String bookAuthor) {
book_author = bookAuthor;
}
public String getBook_publish() {
return book_publish;
}
public void setBook_publish(String bookPublish) {
book_publish = bookPublish;
}
public String getCreation_time() {
return creation_time;
}
public void setCreation_time(String creationTime) {
creation_time = creationTime;
}
@Override
public String toString() {
return "BookInfo [book_author=" + book_author + ", book_id=" + book_id
+ ", book_name=" + book_name + ", book_page=" + book_page
+ ", book_price=" + book_price + ", book_publish="
+ book_publish + ", creation_time=" + creation_time + "]";
}
}

BookInfo.java

5.在src下的com.page包下创建PageUtil.java

 package com.page;

 public class PageUtil {
private Integer pageno;
private Integer pagesize;
private Integer totalpage;
private Integer totalcount;
private Integer startrow; public PageUtil() {
} public PageUtil(Integer pageno, Integer pagesize, Integer totalcount) {
this.pageno = pageno;
this.pagesize = pagesize;
this.totalcount = totalcount;
this.setTotalpage(totalcount,pagesize);
this.setStartrow(pageno,pagesize);
} public void setStartrow(Integer pageno, Integer pagesize) {
this.startrow=(pageno-1)*pagesize;
} public void setTotalpage(Integer totalcount, Integer pagesize) {
this.totalpage=totalcount%pagesize==0?totalcount/pagesize:totalcount/pagesize+1; } public Integer getPageno() {
return pageno;
} public void setPageno(Integer pageno) {
this.pageno = pageno;
} public Integer getPagesize() {
return pagesize;
} public void setPagesize(Integer pagesize) {
this.pagesize = pagesize;
} public Integer getTotalpage() {
return totalpage;
} public Integer getTotalcount() {
return totalcount;
} public void setTotalcount(Integer totalcount) {
this.totalcount = totalcount;
} public Integer getStartrow() {
return startrow;
} }

PageUtil.java

6.在src下的com.mapper包下创建BookInfoMapper.java

 package com.mapper;
import java.util.List;
import com.page.PageUtil;
import com.pojo.BookInfo;
public interface BookInfoMapper {
//分页查询
List<BookInfo> findPage(PageUtil pageutil);
//查询总条数
Integer getTotalCout();
//根据主键查询对象
BookInfo findByPrimaryKey(Integer key);
//添加对象
Integer insertBookInfo(BookInfo bookInfo);
//根据主键修改对象
Integer updatePrimaryKey(BookInfo bookInfo);
//根据主键删除
Integer deletePrimaryKey(Integer key);
}

BookInfoMapper.java

7.在src下的com.mapper包下创建BookInfoMapper.xml

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.mapper.BookInfoMapper">
<!-- 分页查询 -->
<select id="findPage" parameterType="PageUtil" resultType="BookInfo">
select * from book_info limit #{startrow},#{pagesize}
</select>
<!-- 获取总条数 -->
<select id="getTotalCout" resultType="Integer">
select count(*) from book_info
</select>
<!-- 查询单条 -->
<select id="findByPrimaryKey" parameterType="Integer" resultType="BookInfo">
select * from book_info where book_id=#{book_id}
</select>
<!-- 添加 -->
<insert id="insertBookInfo" parameterType="BookInfo">
insert into
book_info(book_name,book_author,book_publish,book_page,book_price,creation_time)
values(#{book_name},#{book_author},#{book_publish},#{book_page},#{book_price},#{creation_time})
</insert>
<!-- 修改 -->
<update id="updatePrimaryKey" parameterType="BookInfo">
update book_info
set
book_name=#{book_name},
book_author=#{book_author},
book_publish=#{book_publish},
book_page=#{book_page},
book_price=#{book_price},
creation_time=#{creation_time}
where
book_id=#{id}
</update>
<!-- 删除 -->
<delete id="deletePrimaryKey" parameterType="Integer">
delete from book_info where book_id=#{book_id}
</delete>
</mapper>

BookInfoMapper.xml

8.在src下创建log4j.properties

 log4j.rootLogger=DEBUG, Console  

 #Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n log4j.logger.org.apache=INFO
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG

log4j.properties

9.在src下创建mybaits-config.xml

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "mybatis-3-config.dtd" >
<configuration>
<!-- 别名配置 -->
<typeAliases>
<typeAlias type="com.page.PageUtil" alias="PageUtil"/>
<typeAlias type="com.pojo.BookInfo" alias="BookInfo"/>
</typeAliases> <!-- 和spring结合时,数据源配置在spring --> <!-- 注册映射xml -->
<mappers>
<mapper resource="com/mapper/BookInfoMapper.xml"/>
</mappers>
</configuration>

mybaits-config.xml

10.在src下的com.mapper.impl包下创建BookInfoMapperImpl.java

 package com.mapper.impl;

 import java.util.List;

 import org.apache.ibatis.session.SqlSessionManager;
import org.mybatis.spring.SqlSessionTemplate; import com.mapper.BookInfoMapper;
import com.page.PageUtil;
import com.pojo.BookInfo; public class BookInfoMapperImpl implements BookInfoMapper {
//定义sqlsession模板对象的
private SqlSessionTemplate sqlSessionTemplate;
//提供sqlsqlsession模板对象的getter和setter
public SqlSessionTemplate getSqlSessionTemplate() {
return sqlSessionTemplate;
}
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSessionTemplate = sqlSessionTemplate;
} //------------------------------
public Integer deletePrimaryKey(Integer key) {
BookInfoMapper mapper=sqlSessionTemplate.getMapper(BookInfoMapper.class);
return mapper.deletePrimaryKey(key);
} public BookInfo findByPrimaryKey(Integer key) {
BookInfoMapper mapper=sqlSessionTemplate.getMapper(BookInfoMapper.class);
return mapper.findByPrimaryKey(key);
} public List<BookInfo> findPage(PageUtil pageutil) {
BookInfoMapper mapper=sqlSessionTemplate.getMapper(BookInfoMapper.class);
return mapper.findPage(pageutil);
} public Integer getTotalCout() {
BookInfoMapper mapper=sqlSessionTemplate.getMapper(BookInfoMapper.class);
return mapper.getTotalCout();
} public Integer insertBookInfo(BookInfo bookInfo) {
BookInfoMapper mapper=sqlSessionTemplate.getMapper(BookInfoMapper.class);
return mapper.insertBookInfo(bookInfo);
} public Integer updatePrimaryKey(BookInfo bookInfo) {
BookInfoMapper mapper=sqlSessionTemplate.getMapper(BookInfoMapper.class);
return mapper.updatePrimaryKey(bookInfo);
} }

BookInfoMapperImpl.java

11.在src下的com.service包下创建BookInfoService.java

 package com.service;
import java.util.List;
import com.page.PageUtil;
import com.pojo.BookInfo;
public interface BookInfoService {
//分页查询
List<BookInfo> queryAll(PageUtil pageutil);
//查询总条数
Integer getTotalCout();
//根据主键查询对象
BookInfo findBookInfo(Integer key);
//添加对象
Integer saveBookInfo(BookInfo bookInfo);
//根据主键修改对象
Integer editBookInfo(BookInfo bookInfo);
//根据主键删除
Integer deleteBookInfo(Integer key);
}

BookInfoService.java

12.在src下的com.service.impl包下创建BookInfoServiceImpl.java

 package com.service.impl;

 import java.util.List;

 import com.mapper.BookInfoMapper;
import com.page.PageUtil;
import com.pojo.BookInfo;
import com.service.BookInfoService; public class BookInfoServiceImpl implements BookInfoService {
//定义数据访问层对象,值由spring通过setter注入
private BookInfoMapper mapper; public BookInfoMapper getMapper() {
return mapper;
} public void setMapper(BookInfoMapper mapper) {
this.mapper = mapper;
}
//----------------------------
public Integer deleteBookInfo(Integer key) {
return mapper.deletePrimaryKey(key);
} public Integer editBookInfo(BookInfo bookInfo) {
return mapper.updatePrimaryKey(bookInfo);
} public BookInfo findBookInfo(Integer key) {
return mapper.findByPrimaryKey(key);
} public Integer getTotalCout() {
return mapper.getTotalCout();
}
public List<BookInfo> queryAll(PageUtil pageutil) {
return mapper.findPage(pageutil);
} public Integer saveBookInfo(BookInfo bookInfo) {
// TODO Auto-generated method stub
return null;
} }

BookInfoServiceImpl.java

13.在src下的com.servlet包下创建BookInfoServlet.java

 package com.servlet;

 import java.io.IOException;
import java.io.PrintWriter;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.page.PageUtil;
import com.pojo.BookInfo;
import com.service.BookInfoService;
import com.service.impl.BookInfoServiceImpl; public class BookInfoServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//1.乱码处理
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8"); //2.接收请求参数
String flag=request.getParameter("flag"); //3.加载spring的xml文件
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml"); //4.由于原来sevelt调用service
//在此处调用springxml中的service的bean节点,获取service对象
BookInfoServiceImpl serviceImpl=(BookInfoServiceImpl) ac.getBean("bookInfoServiceImpl"); //5.业务处理
if(flag==null){ //5.1 分页查询
//获取第二次页面分页超链接请求“当前页的”参数的值
String strpageno=request.getParameter("pageno");
//定义第一次请求当前页的的默认值
Integer pageno=1;
//判断是否是第二次请求。由于页面上的参数全部是string类型,所以转换
if(strpageno!=null){
pageno=Integer.valueOf(strpageno);
}
//定义页面大小
Integer pagesize=3;
//查询总条数
Integer totalcount=serviceImpl.getTotalCout();
//计算总页数
Integer totalpage=totalcount%pagesize==0?totalcount/pagesize:totalcount/pagesize+1;
//封装分页参数给工具类
PageUtil pageutil=new PageUtil(pageno, pagesize, totalcount);
//执行分页查询操作
List<BookInfo> list=serviceImpl.queryAll(pageutil);
if(list!=null){
System.out.println("find success");
request.setAttribute("list", list);
request.getRequestDispatcher("index.jsp").forward(request, response);
}else{
System.out.println("find fail");
}
}else if(flag=="add"){ } } }

BookInfoServlet.java

14.在WebRoot下的WEB-INF下编辑web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet>
<servlet-name>BookInfoServlet</servlet-name>
<servlet-class>com.servlet.BookInfoServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>BookInfoServlet</servlet-name>
<url-pattern>/BookInfoServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>BookInfoServlet</welcome-file>
</welcome-file-list>
</web-app>

web.xml

15.在src下创建applicationContext.xml

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
<!-- ☆ 1.数据源配置:驱动管理数据源 -->
<!--
类似java的:DriverManagerDataSource dataSource=new DriverManagerDataSource();
-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!--类似java的:dataSource.setDriverClassName("com.mysql.jdbc.Driver"); -->
<property name="driverClassName" value="com.mysql.jdbc.Driver"/> <!--类似java的:dataSource.setUrl("jdbc:mysql://localhost:3306/holly"); -->
<property name="url" value="jdbc:mysql://localhost:3306/holly"/> <!--类似java的:dataSource.setUsername("root"); -->
<property name="username" value="root"/> <!--类似java的:dataSource.setPassword("ok"); -->
<property name="password" value="ok"/>
</bean> <!-- ☆ 2.sqlsessionfactoryBean -->
<!--类似java的:SqlSessionFactoryBean sqlSessionFactoryBean=new SqlSessionFactoryBean(); -->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 2.1 引入数据源 -->
<!--类似java的:sqlSessionFactoryBean.setDataSource(dataSource); -->
<property name="dataSource" ref="dataSource"/> <!-- 2.2 加载mybatis主配置文件 -->
<!--类似java的:sqlSessionFactoryBean.setConfigLocation("classpath:mybaits-config.xml"); -->
<property name="configLocation">
<value>classpath:mybaits-config.xml</value>
</property>
</bean> <!-- 3.sqlsessionTemplate -->
<!--类似java的:SqlSessionTemplate sqlSessionTemplate=new SqlSessionTemplate(sqlSessionFactoryBean); -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<!-- 通过构造赋值 -->
<constructor-arg ref="sqlSessionFactoryBean"/>
</bean> <!-- 4.数据访问层的注入:new对象完成赋值 -->
<!--BookInfoMapperImpl bookInfoMapper=new BookInfoMapperImpl(); -->
<bean id="bookInfoMapperImpl" class="com.mapper.impl.BookInfoMapperImpl">
<!--bookInfoMapper.setSqlSessionTemplate(sqlSessionTemplate); -->
<property name="sqlSessionTemplate" ref="sqlSessionTemplate"/>
</bean> <!-- 5.业务层的的注入:new对象完成赋值 -->
<!--BookInfoServiceImpl bookInfoServiceImpl=new BookInfoServiceImpl(); -->
<bean id="bookInfoServiceImpl" class="com.service.impl.BookInfoServiceImpl">
<!--bookInfoServiceImpl.setBookInfoMapper(bookInfoMapperImpl); -->
<property name="mapper" ref="bookInfoMapperImpl"/>
</bean> </beans>

applicationContext.xml

16.在WebRoot下编辑index.jsp

 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head> <body>
<center>
<fieldset>
<legend>图书信息</legend>
<a href="add.jsp">保存图书信息</a>
<table border="1">
<tr>
<td>编号</td>
<td>书名</td>
<td>作者</td>
<td>出版社</td>
<td>页数</td>
<td>价格</td>
<td>出版时间</td>
<td>操作</td>
</tr>
<c:forEach var="i" items="${list}">
<tr>
<td>${i.book_id}</td>
<td>${i.book_name}</td>
<td>${i.book_author}</td>
<td>${i.book_publish}</td>
<td>${i.book_page}</td>
<td>${i.book_price}</td>
<td>${i.creation_time}</td>
<td>
<a href="BookInfoServlet?flag=findbyid&id=${i.book_id}">修改</a>
|
<a href="BookInfoServlet?flag=delete&id=${i.book_id}">删除</a>
</td>
</tr>
</c:forEach>
</table>
</fieldset>
</center>
</body>
</html>

index.jsp

17.运行

本文原创,如有问题,请联系holly老师:转载请备注出处!

9.Spring的IOC+MyBaits+log4j+Servlet的更多相关文章

  1. 在Servlet(或者Filter,或者Listener)中使用spring的IOC容器

    web.xml中的加载顺序为:listener > filter > servlet > spring. 其中filter的执行顺序是filter-mapping在web.xml中出 ...

  2. Spring之IOC原理及代码详解

    一.什么是IOC 引用 Spring 官方原文:This chapter covers the Spring Framework implementation of the Inversion of ...

  3. Spring框架IOC和AOP介绍

    说明:本文部分内容参考其他优秀博客后结合自己实战例子改编如下 Spring框架是个轻量级的Java EE框架.所谓轻量级,是指不依赖于容器就能运行的.Struts.Hibernate也是轻量级的. 轻 ...

  4. Spring的IOC和AOP之深剖

    今天,既然讲到了Spring 的IOC和AOP,我们就必须要知道 Spring主要是两件事: 1.开发Bean:2.配置Bean.对于Spring框架来说,它要做的,就是根据配置文件来创建bean实例 ...

  5. Spring 实践 -IoC

    Spring 实践 标签: Java与设计模式 Spring简介 Spring是分层的JavaSE/EE Full-Stack轻量级开源框架.以IoC(Inverse of Control 控制反转) ...

  6. Spring 的IOC容器之XML方式

    1. Spring 入门 1.1 概述 Spring 是一个分层的 JavaEE 轻量级开源框架; Spring 的核心是控制反转(IOC)和面向切面(AOP); 1.2 特点 方便解耦,简化开发; ...

  7. Spring 的IOC 和Aop

    Spring 的IOC 和Aop

  8. Spring 实现 IoC

    理解 “ 控制反转(IoC)”   控制反转(IoC):用白话来讲,就是由 Spring 容器控制程序中类与类之间的关系,而非传统实现中,由程序代码直接操控.这也就是所谓 “控制反转” 的概念所在:控 ...

  9. # Spring 练习ioc 、aop

    Spring 练习 通过学习spring的基础知识,了解了Spring为了降低Java开发的复杂性,采取了以下4种关键策略: 基于POJO的轻量级和最小侵入性编程: 通过依赖注入和面向接口实现松耦合: ...

随机推荐

  1. VIM 移动

    基础 字符移动 k 上移 k h 左移 h l l 右移 j j 下移 你也可以使用键盘上的方向键来移动,但这么做h j k l的存在就失去了意义 之所以使用h j k l来控制方向,其主要目的是让你 ...

  2. 通过指针访问C++对象的私有成员

    C++对象的私有成员是禁止类外的访问的.但是我们仍然可以通过指针访问C++对象的私有成员. #include <iostream> using namespace std; class A ...

  3. Android按键添加和处理的方案【转】

    本文转载自:http://www.cnblogs.com/skywang12345/p/3142851.html Android按键添加和处理的方案  版本号 说明 作者 日期  1.0  Andro ...

  4. 杂项-Java:JNI

    ylbtech-杂项-Java:JNI JNI是Java Native Interface的缩写,它提供了若干的API实现了Java和其他语言的通信(主要是C&C++).从Java1.1开始, ...

  5. Java常用类及反射,类加载

    1.系统相关类 Java提供了System类和Runtime类来与程序运行的平台进行交互 A.System类代表当前Java程序的运行平台 a. System类是一个final类,该类的所有属性和方法 ...

  6. 截取字符(substr)检索字符位置(instr)

    1.SUBSTR(string,start_position,[length]) 求子字符串,返回字符串注释: string 元字符串start_position 开始位置(从0开始)length 可 ...

  7. .sh文件 编写格式

    http://blog.sina.com.cn/s/blog_54f82cc201010hfz.html 介绍: 1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号# ...

  8. 使用node成功安装完某插件typescript后,在使用时提示:tsc(或xxx)不是内部或外部命令,也不是可运行的程序或批处理文件

    具体出错情形: 使用npm安装typescript明明安装成功,但在使用时一直报错,报错语句为  tsc不是内部或外部命令,也不是可运行的程序或批处理文件 具体出错原因: node未正确安装,或相关环 ...

  9. R - Games

    Problem description Manao works on a sports TV. He's spent much time watching the football games of ...

  10. python 字符编码的两种方式写法:# coding=utf-8和# -*- coding:utf-8 -*-

    python运行文件是总会出现乱码问题,为了解决这个问题,在文件开头加上: # coding=utf-8 或者 # -*- coding:utf-8  -*- # coding=<encodin ...