資源簡介
簡單javaweb登陸注冊界面,適合初學者學習

代碼片段和文件信息
package?com.northwind.actions;
import?java.io.IOException;
import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
public?class?UserAction?extends?HttpServlet?{
/**
?*?
?*/
private?static?final?long?serialVersionUID?=?1L;
/**
?*?Constructor?of?the?object.
?*/
public?UserAction()?{
super();
}
/**
?*?Destruction?of?the?servlet.?
?*/
public?void?destroy()?{
super.destroy();?//?Just?puts?“destroy“?string?in?log
//?Put?your?code?here
}
/**
?*?The?doGet?method?of?the?servlet.?
?*?
?*?This?method?is?called?when?a?form?has?its?tag?value?method?equals?to?get.
?*?
?*?@param?request
?*????????????the?request?send?by?the?client?to?the?server
?*?@param?response
?*????????????the?response?send?by?the?server?to?the?client
?*?@throws?ServletException
?*?????????????if?an?error?occurred
?*?@throws?IOException
?*?????????????if?an?error?occurred
?*/
public?void?doGet(HttpServletRequest?request?HttpServletResponse?response)
throws?ServletException?IOException?{
doPost(request?response);
}
/**
?*?The?doPost?method?of?the?servlet.?
?*?
?*?This?method?is?called?when?a?form?has?its?tag?value?method?equals?to
?*?post.
?*?
?*?@param?request
?*????????????the?request?send?by?the?client?to?the?server
?*?@param?response
?*????????????the?response?send?by?the?server?to?the?client
?*?@throws?ServletException
?*?????????????if?an?error?occurred
?*?@throws?IOException
?*?????????????if?an?error?occurred
?*/
@SuppressWarnings(“unchecked“)
public?void?doPost(HttpServletRequest?request?HttpServletResponse?response)
throws?ServletException?IOException?{
//?獲取前臺的內(nèi)容
String?method?=?request.getParameter(“method“);
String?loginid?=?request.getParameter(“l(fā)oginid“);
String?password?=?request.getParameter(“password“);
@SuppressWarnings(“unused“)
String?msg?=?““;?//?前臺頁面顯示的內(nèi)容
if?(method?==?null)?{
request.getRequestDispatcher(“/Pages/login.jsp“).forward(request
response);
}?else?if?(“l(fā)ogin“.equals(method))?{
if?(loginid?==?““)?{?//?如果用戶名為空,直接返回錯誤信息
request.setAttribute(“msg“?“此用戶不存在“);
request.getRequestDispatcher(“/Pages/login.jsp“).forward(
request?response);
}?else?if?(loginid.equals(“admin“)
&&?password.equals(“admin“))?{
request.getRequestDispatcher(“/Pages/success.jsp“).forward(
request?response);
}?else?{
request.setAttribute(“msg“?“用戶名或密碼錯誤“);
request.getRequestDispatcher(“/Pages/login.jsp“).forward(
request?response);
}
}
}
/**
?*?Initialization?of?the?servlet.?
?*?
?*?@throws?ServletException
?*?????????????if?an?error?occurs
?*/
public?void?init()?throws?ServletException?{
//?Put?your?code?here
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2012-05-25?10:38??ServerletWeb
?????文件????????362??2012-05-25?10:38??ServerletWeb\.classpath
?????目錄??????????0??2012-05-25?10:38??ServerletWeb\.myeclipse
?????文件????????309??2012-05-25?10:38??ServerletWeb\.myme
?????文件???????1418??2012-05-25?11:04??ServerletWeb\.project
?????目錄??????????0??2012-05-25?10:38??ServerletWeb\.settings
?????文件????????406??2012-05-25?10:38??ServerletWeb\.settings\.jsdtscope
?????文件?????????49??2012-05-25?10:38??ServerletWeb\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2012-05-25?10:38??ServerletWeb\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\src
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\src\com
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\src\com\northwind
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\src\com\northwind\actions
?????文件???????2969??2012-05-25?10:52??ServerletWeb\src\com\northwind\actions\UserAction.java
?????目錄??????????0??2012-05-25?10:52??ServerletWeb\WebRoot
?????目錄??????????0??2012-05-25?10:38??ServerletWeb\WebRoot\me
?????文件?????????39??2012-05-25?10:38??ServerletWeb\WebRoot\me
?????目錄??????????0??2012-05-25?10:52??ServerletWeb\WebRoot\Pages
?????文件????????924??2012-05-25?08:29??ServerletWeb\WebRoot\Pages\login.jsp
?????文件????????228??2012-05-25?08:29??ServerletWeb\WebRoot\Pages\success.jsp
?????目錄??????????0??2012-05-25?10:38??ServerletWeb\WebRoot\WEB-INF
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\WebRoot\WEB-INF\classes
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\WebRoot\WEB-INF\classes\com
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\WebRoot\WEB-INF\classes\com\northwind
?????目錄??????????0??2012-05-25?10:39??ServerletWeb\WebRoot\WEB-INF\classes\com\northwind\actions
?????文件???????1965??2012-05-25?10:52??ServerletWeb\WebRoot\WEB-INF\classes\com\northwind\actions\UserAction.class
?????目錄??????????0??2012-05-25?10:38??ServerletWeb\WebRoot\WEB-INF\lib
?????文件????????701??2012-05-25?11:04??ServerletWeb\WebRoot\WEB-INF\web.xm
-----------?---------??----------?-----??----
?????????????????9376????????????????????28
............此處省略1個文件信息
評論
共有 條評論