用jsp将xml文件解析到网页显示,并把数据提交保存到数据库(6)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:33 点击:次
<%@ page language="java" import="java.util.*"%>
<%
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%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>QUESTION_SAVES</title>
</head>
<body background="#123456">
<%
//驱动程序名
String driverName="com.mysql.jdbc.Driver";
//数据库用户名
String userName="root";
//密码
String userPasswd="520123412";
//数据库名
String dbName="xml";
//连接字符串
String url="jdbc:mysql://localhost:3306/"+dbName+"?user="+userName+"&password="+userPasswd+"&useUnicode=true&characterEncoding=UTF-8";
//加载驱动程序
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
request.setCharacterEncoding("UTF-8");
String question_id=request.getParameter("question_id");
String username=request.getParameter("username");
if(username!=null&&username!=""){
Map map=request.getParameterMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
// Object val = entry.getValue();
if(((String)entry.getKey()).matches("sing_[0-99]_[0-99]")){
try{
String sing= request.getParameter((String)entry.getKey());
String[] str=((String)entry.getKey()).split("_");
//out.println("<p>"+str[0]+":"+str[1]+":"+str[2]+"</p>");
//out.println("<p>"+entry.getKey()+":"+request.getParameter((String)entry.getKey())+"</p>");
相关新闻>>
- 发表评论
-
- 最新评论 更多>>