zoukankan      html  css  js  c++  java
  • 网上书城随笔

    1.request.getContextPath()拿到的是你的web项目的根路径,就是webRoot。
    绝对路径-以Web站点根目录为参考基础的目录路径。之所以称为绝对,意指当所有网页引用同一个文件时,所使用的路径都是一样的。
    相对路径-以引用文件之网页所在位置为参考基础,而建立出的目录路径。因此,当保存于不同目录的网页引用同一个文件时,所使用的路径将不相同,故称之为相对。

    2.在<jsp:useBean >内定义的,可以直接用EL表达式调用。

    3..properties 文件内获取属性

    InputStream fin = getClass().getResourceAsStream(
                        this.getPropertyFileName());//获得动态路径
                Properties props = new Properties();
                props.load(fin);
                return (String) props.getProperty(属性名);

    4.数据库连接:http://www.cnblogs.com/cy163/archive/2008/08/22/1274413.html

    Class.forName("com.mysql.jdbc.Driver");//加载及注册JDBC驱动程序
    String url="jdbc:mysql://localhost:3306/sample_db?user=root&password=your_password";
    Connection con = DriverManager.getConnection(url);//建立连接对象
    Statement stmt = con.createStatement();//建立SQL陈述式对象
    String query = "select * from test";
    ResultSet rs=stmt.executeQuery(query);//执行SQL语句
    while(rs.next())  //结果集ResultSet
    
    {rs.getString(1);rs.getInt(2);}
    
    String upd="insert into test (id,name) values(1001,xuzhaori)";
    
    int con=stmt.executeUpdate(upd);
    
    PreparedStatement stmt = conn.prepareStatement("insert into test(id,name)values(?,?)");  //PreparedStatement(预编语句)
    
    stmt.setInt(1,id);
    
    stmt.setString(2,name);
  • 相关阅读:
    hdu2328 Corporate Identity
    hdu1238 Substrings
    hdu4300 Clairewd’s message
    hdu3336 Count the string
    hdu2597 Simpsons’ Hidden Talents
    poj3080 Blue Jeans
    poj2752 Seek the Name, Seek the Fame
    poj2406 Power Strings
    hust1010 The Minimum Length
    hdu1358 Period
  • 原文地址:https://www.cnblogs.com/liu-Gray/p/5237592.html
Copyright © 2011-2022 走看看