码迷,mamicode.com
首页 > 编程语言 > 详细

java技术整理

时间:2014-11-03 20:47:02      阅读:232      评论:0      收藏:0      [点我收藏+]

标签: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"));

java技术整理

标签:style   http   io   color   ar   java   sp   文件   on   

原文地址:http://www.cnblogs.com/funshareba/p/4071960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!