?? loginaction.java
字號:
package com.ajxa.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ajxa.struts.form.LoginForm;
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//LoginForm loginForm = (LoginForm) form;
try{
request.setCharacterEncoding("gb2312");
}catch(Exception e){
System.out.print(e);
}
try{ //ActionErrors errors=new ActionErrors();
String msgStr="";
response.setContentType("text/xml;charset=GB2312");
response.setHeader("Cache-Control","no-cache");
String name=(String)request.getParameter("name");
System.out.println("name = "+name);
if("gong".equals(name)){ //找查數(shù)據(jù)庫中有無該用戶名
msgStr ="對不起,此用戶名已經(jīng)存在,請更換用戶名注冊!";
//errors.add("msg", new ActionError("same")) ;
}else{
msgStr ="用戶未被注冊,可以使用!";
//errors.add("msg", new ActionError("notsame")) ;
}
// request.setAttribute("msg", msgStr);
response.getWriter().println("<?xml version='1.0' encoding='GB2312' ?>");
response.getWriter().println("<root>");
response.getWriter().println("<content>");
response.getWriter().print(msgStr);
response.getWriter().println("</content>");
response.getWriter().println("</root>");
response.getWriter().close();
}catch(Exception ex){
}
return null;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -