jsp登录代码追踪(求助)
刚学jsp,有很多地方还搞不懂,网上找了份项目源码,代码不全。利用这些源码学习,现在追踪代码,追着追着追不下去了,求网友指点:login—sub.jsp文件
<%@page contentType="text/html;charset=GBK" %>
<jsp:useBean id="fguserForm" class="com.keyshop.shop.user.controller.UserForm" scope="request"/>
<script>
//Function trim a string
function trim(Str , Flag)
{
Str = ""+Str;
if( Flag == "l" || Flag == "L" )/*trim left side only*/
{
RegularExp = /^\s+/gi;
return Str.replace( RegularExp,"" );
}
else if( Flag == "r" || Flag == "R" )/*trim right side only*/
{
RegularExp = /\s+$/gi;
return Str.replace( RegularExp,"" );
}
else/*defautly, trim both left and right side*/
{
RegularExp = /^\s+|\s+$/gi;
return Str.replace( RegularExp,"" );
}
}
function submitFormReg(){
window.location="userreg.do?actionType=regsetp1";
}
function submitForm() {
if(trim(document.all['bean.id'].value) == "") {
alert("请输入用户名");
document.all['bean.id'].focus();
return;
}
if(trim(document.all['bean.password'].value) == "") {
alert("请输入密码");
document.all['bean.password'].focus();
return;
}
document.fguserForm.submit();
}
function clearForm() {
document.all['bean.id'].value ="";
document.all['bean.password'].value="";
}
</script>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i01.gif" width="10" height="10"></td>
<td background="<%=CONTEXT%>/img/QQ/i03.gif"></td>
<td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i02.gif" width="10" height="10"></td>
</tr>
<tr>
<td background="<%=CONTEXT%>/img/QQ/i04.gif"> </td>
<td>
<!--主题内容开始-->
<html:form method="post" action="/fg/user/user">
<html:hidden property="channelId" value="<%=currentChannel.getId()%>"/>
<input type="hidden" name="actionType" value="login"/>
<html:hidden property="requestPageUrl"/>
<table width="531" border="0" align="center" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<table width="565" border="0" cellpadding="0" cellspacing="0" class="Process01_product_navimg01">
<tr>
<td align="center" class="Process01_product_navtext">用户登录</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="Process01_product_navimg02">
<tr>
<td valign="top"><br>
<table width="300" border="0" cellspacing="2" cellpadding="2">
<%
String loginError = (String)request.getAttribute("login_error");
if(!StringUtil.isEmpty(loginError)) {
%>
<tr>
<td align="center">无效的用户名或密码</td>
</tr>
<%
}
%>
<tr>
<td align="right" class="Process01_product_navtext02">用户名:</td>
<td height="25" align="left">
<html:text styleClass="i03" property="bean.id" value="" size="18" maxlength="32"/>
</td>
</tr>
<tr>
<td align="right" class="Process01_product_navtext02">密 码:</td>
<td height="25" align="left">
<html:password styleClass="i03" property="bean.password" value="" size="18" maxlength="32"/></td>
</tr>
<tr>
<td align="right"> </td>
<td align="center">
<input type="button" onclick="javascript:submitForm()" value="登录">
<input type="button" onclick="javascript:submitFormReg()" value="注册">
</td>
</tr>
<tr>
<td align="right"> </td>
<td height="40" align="center" valign="bottom">
<a href="<%=GETPASSWORD%>" class="Process01_product_pname01">忘记密码?</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="565" border="0" cellpadding="0" cellspacing="0" class="Process01_product_navimg03">
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</html:form>
<!--主体内容结束-->
</td>
<td background="<%=CONTEXT%>/img/QQ/i05.gif"></td>
</tr>
<tr>
<td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i06.gif" width="10" height="10"></td>
<td background="<%=CONTEXT%>/img/QQ/i08.gif"></td>
<td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i07.gif" width="10" height="10"></td>
</tr>
</table>
-------------------------------------------------------
UserAction.java文件
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: UserAction.java
package com.keyshop.shop.user.controller;
import com.keyshop.pub.controller.PubAction;
import com.keyshop.pub.controller.PubForm;
import com.keyshop.pub.model.PubBean;
import com.keyshop.pub.util.*;
import com.keyshop.shop.system.manager.SystemManager;
import com.keyshop.shop.system.model.MailConfig;
import com.keyshop.shop.system.model.ViewConfig;
import com.keyshop.shop.user.bo.UserBO;
import com.keyshop.shop.user.model.User;
import java.util.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
// Referenced classes of package com.keyshop.shop.user.controller:
// UserForm
public class UserAction extends PubAction
{
public static final String USER = "User";
public UserAction()
{
}
public String getSelectSQL()
{
return null;
}
public void initClassName()
{
}
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return super.execute(mapping, form, request, response);
}
public ActionForward performList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("fail");
}
public ActionForward performRegsetp1(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("regsetp1");
}
public ActionForward performRegsetp2(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("regsetp2");
}
public ActionForward performGologin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("login");
}
public ActionForward performLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return null;
}
public ActionForward performLogout(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return null;
}
public ActionForward performAccountview(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("accountview");
}
public ActionForward performRegedit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("regedit");
}
public ActionForward performRegupdate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return null;
}
private void goUrl(String requestPageUrl, String param)
throws Exception
{
}
public ActionForward performSpeedcreate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("login");
}
public ActionForward performRegsetp3(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("regsetp3");
}
private void sendUserCreateMail(User user, ViewConfig viewConfig)
{
}
public ActionForward performUpdate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("edit");
}
public ActionForward performRemove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("fail");
}
protected boolean isObjectExisted(PubBean bean)
{
return false;
}
protected boolean isEmailExisted(PubBean bean)
{
return false;
}
} --------------------编程问答-------------------- 亲,扫了一遍,没有发现你问的问题在哪啊? --------------------编程问答-------------------- 好黑好长好邪恶! --------------------编程问答-------------------- 我不知道UserAction.java是怎么处理login—sub.jsp中的登录form的? --------------------编程问答-------------------- 你想作甚。。 --------------------编程问答-------------------- 网上找来一个残缺不全的项目源码,企图串联起来,把其中的代码全部读懂,甚至让它跑起来。 --------------------编程问答-------------------- --------------------编程问答--------------------
jsp页面中点击“登录”按钮调用javascript函数 submitForm(),
判断用户名、密码后提交页面
document.fguserForm.submit();
通过<html:form method="post" action="/fg/user/user">指定的action,
jsp转向到UserAction
UserAction执行execute方法
execute方法中又调用父类(UserAction继承的UpAction)的execute方法
return super.execute(mapping, form, request, response);
--------------------编程问答--------------------
谢七楼朋友
UserAction父类代码:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: PubAction.java
package com.keyshop.pub.controller;
import com.keyshop.pub.model.PubBean;
import com.keyshop.pub.security.model.User;
import com.keyshop.pub.util.*;
import com.keyshop.shop.system.manager.SystemManager;
import com.keyshop.shop.system.model.MailConfig;
import com.keyshop.shop.system.model.ViewConfig;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.*;
import javax.servlet.http.*;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.apache.struts.action.*;
public abstract class PubAction extends Action
{
}
-----------------------------
这源码发布者实在可恶,二级页面全部删掉,最底层操作数据库的部分也几乎全部拿掉了。纯碎是打广告,骗人买他的源码。 --------------------编程问答-------------------- 初看之下,方法里面什么都没有! --------------------编程问答-------------------- 想要跑起来这个就要自己写很很多的东西!还是自己重新写一个项目比较快
去弄个SSH框架,自己搞吧! --------------------编程问答-------------------- 再重新上网下个能用的吧。 --------------------编程问答-------------------- 谢谢10、11楼朋友鼓励哟! --------------------编程问答--------------------
今天又在csdn上下了一个,一看就崩溃了,简直是搬宝的,我愤怒!!! --------------------编程问答--------------------
可能就是同一个人…… --------------------编程问答-------------------- 百度文库上就有,先看好再下。
补充:Java , Web 开发