clientshowinfaction.java

来自「电子商务网站使用MVC模式B/S结构功能不是很全适合初学者看」· Java 代码 · 共 54 行

JAVA
54
字号
package Client;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.util.ArrayList;
import Common.DBConnectBean;
public class clientShowInfAction extends HttpServlet{
	public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
		ServletContext application=getServletConfig().getServletContext(); 
		DBConnectBean dbConnectBean=new DBConnectBean("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:shopping","","");
		request.setCharacterEncoding("gb2312");
		HttpSession session=request.getSession();
		if(session.getAttribute("username".toUpperCase())!=null){
			String username=session.getAttribute("username".toUpperCase()).toString();
	/*-------------先解决人气排行*/
			Hashtable table=dbConnectBean.getOneRecord("select * from client where username='"+username+"'");
			String sex="",identifyCard="",qq="",email="",phone="",address="",describe="";
			//System.out.println("list有这么大"+list.size());
			if(table!=null){	
				sex=table.get("sex".toUpperCase()).toString();
				identifyCard=table.get("identifyCard".toUpperCase()).toString();
				qq=table.get("qq".toUpperCase()).toString();
				email=table.get("email".toUpperCase()).toString();
				phone=table.get("phone".toUpperCase()).toString();
				address=table.get("address".toUpperCase()).toString();
				describe=table.get("describe".toUpperCase()).toString();
				
				table.put("username".toUpperCase(),username);
				table.put("sex".toUpperCase(),sex);
				table.put("identifyCard".toUpperCase(),identifyCard);
				table.put("qq".toUpperCase(),qq);
				table.put("email".toUpperCase(),email);
				table.put("phone".toUpperCase(),phone);
				table.put("address".toUpperCase(),address);
				table.put("describe".toUpperCase(),describe);
				//System.out.println("str是"+str);
				//System.out.println("id是"+id);
			
			}
			//System.out.println("temp有这么大"+temp.size());
			//这个是所有用户共同拥有的,所以用application来保存
			session.setAttribute("clientInf".toUpperCase(),table);
			application.getRequestDispatcher("/client/clientShowInf.jsp").forward(request,response);
		}else{
			application.getRequestDispatcher("/client/clientList.jsp?logged=false").forward(request,response);
		}
	}
	public void doPost(HttpServletRequest request,HttpServletResponse response)
	   throws IOException,ServletException
	   {
	   	doGet(request,response);
	   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?