- 浏览: 101520 次
- 性别:
- 来自: 成都
最新评论
文章列表
index页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"errorPage="test.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getSe ...
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
...
登录页面:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/" ...
在数据库中输入查询语句select * from table where name='中文',有一条结果集。
但是用java来查询同样一条语句结果集却为空上网找很久,加一句话就能连接了.....郁闷!!!
connection = DriverManager.getConnection(
"jdbc:mysql://localhost/test?user=root&password=&useUnicode=true&characterEncoding=GBK" );
红字这一段,目的是告诉jdbc drive ...
本例需要mail.jar activation.jar可以到官网下载
表单页:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request ...
JavaBean技术不但实现了表现层和商务逻辑层的分离,而且提高了JSP的效率和代码重用的程度,是JSP编程中常用的技术
下面是一个简单的JavaBean实例
java代码:
package com.javaBean.vo;
public class FirstJavaBean {
private String firstPorperty=new String("");
public FirstJavaBean(){
}
public String getFirstProperty(){
return ...
连接Mysql数据库:
注册驱动: Class.forName("com.mysql.jdbc.Driver").newInstance();
获取连接: con=DriverManager.getConnection("jdbc:mysql://localhost/数据库名?user=用户名&password=密码");
连接sql server数据库:
注册驱动: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
...
本例运行在Tomact服务器下一切正常:
生成验证码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="java.awt.Color"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="java.awt.Graphics&q ...
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out=response.getWriter();
HttpSession session=request.ge ...
mysql jdbc驱动下载地址:
http://pan.baidu.com/share/link?shareid=22738&uk=2366527449
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MysqlConnection {
public Connection getConnection(){
Connection con=null;
/**
* 注册驱动
* ...
public void openApp(){
String url="C:\\WINDOWS\\system32\\calc.exe";
try {
Runtime.getRuntime().exec(url);
} catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
}
在conf目录下的server.xml 中增加URIEncoding="UTF-8"
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
MSSQLserver中,的三种分页方式:
select top 页大小 * from 表 where id not in(select top 面大小*(页数-1) id from 表 order by id) order by id
select top 页大小 * from 表 where id>(select isnull(max(id),0) from (select top 页大小*(页数-1) id from 表order by id)a) order by id
select top 页大小 * from (select row_number() o ...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; char ...
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
...