标签:style http io color ar java sp 文件 on
//c3po连接池
ComboPooledDataSource cs = new ComboPooledDataSource();
//测试dbutils
Bookbean book = new Bookbean(123,"书报","非常棒");
Object[] params = {null,"苹果","甜"};
QueryRunner qr = new QueryRunner(cs);
String sql = "insert into t_booktype values (?,?,?)";
qr.update(sql,params);
//servlet纯手工配置 web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" metadata-complete="true">
<servlet>
<servlet-name>demo</servlet-name>
<servlet-class>cn.minipai.demo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>demo</servlet-name>
<url-pattern>/aaa</url-pattern>
</servlet-mapping>
</web-app>
//路径目录
demo
|--WEB-INF(文件夹)
|--classes(文件夹)
|--demo.java
|--.class文件
|--web.xml
//servlet读取资源文件
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
InputStream in = this.getServletContext().getResourceAsStream("/WEB-INF/classes/db.properties");
Properties props = new Properties();
props.load(in);
System.out.println(props.getProperty("database"));
标签:style http io color ar java sp 文件 on
原文地址:http://www.cnblogs.com/funshareba/p/4071960.html