Integer user_id=(Integer) session.getAttribute("user_id");到底什么意思在下面的代码中表示什么
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletE...
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
Text text=new Text();
String title=request.getParameter("title");
String conten=request.getParameter("content");
Date now=new Date();
HttpSession session = request.getSession();
Integer user_id=(Integer) session.getAttribute("user_id");
text.setText_addtime(now);
text.setText_content(conten);
text.setText_title(title);
textManager tm=new textManager();
int rs= tm.addbook(text, user_id);
if(rs>0){
RequestDispatcher dispatcher = request.getRequestDispatcher("ok.jsp?msg=添加");
dispatcher.forward(request, response);
}else{
RequestDispatcher dispatcher = request.getRequestDispatcher("fail.jsp?msg=添加");
dispatcher.forward(request, response);
} 展开
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
Text text=new Text();
String title=request.getParameter("title");
String conten=request.getParameter("content");
Date now=new Date();
HttpSession session = request.getSession();
Integer user_id=(Integer) session.getAttribute("user_id");
text.setText_addtime(now);
text.setText_content(conten);
text.setText_title(title);
textManager tm=new textManager();
int rs= tm.addbook(text, user_id);
if(rs>0){
RequestDispatcher dispatcher = request.getRequestDispatcher("ok.jsp?msg=添加");
dispatcher.forward(request, response);
}else{
RequestDispatcher dispatcher = request.getRequestDispatcher("fail.jsp?msg=添加");
dispatcher.forward(request, response);
} 展开
2015-07-10 · 知道合伙人软件行家
关注
展开全部
Integer user_id=(Integer) session.getAttribute("user_id");
从session中取一个叫 user_id 的值
这里就是根据这个值去数据库查了应该,如果成功就转跳到ok.jsp
如果不成功就转到fail.jsp
int rs= tm.addbook(text, user_id);
if(rs>0){
RequestDispatcher dispatcher = request.getRequestDispatcher("ok.jsp?msg=添加");
dispatcher.forward(request, response);
}else{
RequestDispatcher dispatcher = request.getRequestDispatcher("fail.jsp?msg=添加");
dispatcher.forward(request, response);
}
从session中取一个叫 user_id 的值
这里就是根据这个值去数据库查了应该,如果成功就转跳到ok.jsp
如果不成功就转到fail.jsp
int rs= tm.addbook(text, user_id);
if(rs>0){
RequestDispatcher dispatcher = request.getRequestDispatcher("ok.jsp?msg=添加");
dispatcher.forward(request, response);
}else{
RequestDispatcher dispatcher = request.getRequestDispatcher("fail.jsp?msg=添加");
dispatcher.forward(request, response);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询