最近用struts,做个了个登录的东西很简单
做完后测试,每次一到.do的时候就停止不动了
请问怎么回事?
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
TypeSystem</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <servlet>                   
    <servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
     </init-param>
</servlet>
<servlet-mapping>
   <servlet-name>action</servlet-name> 
   <url-pattern>*.do</url-pattern> 
   </servlet-mapping>

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ========== Data Source Configuration =============================== -->
<data-sources /> <!-- ========== Form Bean Definitions ================================== -->
<form-beans>
<form-bean name="formBean1" type="com.lcs.classmate.UserForm"></form-bean>
</form-beans>
<!-- ========== Global Exception Definitions ============================== -->
<global-exceptions />
<!-- ========== Global Forward Definitions =============================== -->
<global-forwards>
<forward name="failed" path="/right.jsp"></forward>
<forward name="success" path="/right.jsp"></forward>
</global-forwards>
<!-- ========== Action Mapping Definitions =============================== -->
<action-mappings>
<action path="/login" type="com.lcs.classmate.Test"
name="formBean1" scope="request" input="/login.html" />

<action path="/regist" forward="/regist.jsp"></action>
</action-mappings>
<!-- ========== Controller Configuration ================================ -->
<controller />
<!-- ========== Message Resources Definitions ============================ -->
<!-- ========== Plug Ins Configuration ================================= -->
<message-resources parameter="com.lee.struts.ApplicationResources" />
</struts-config>package com.lcs.classmate;//导入servlet类
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//导入struts类
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;public final class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletResponse request, HttpServletResponse response)
throws Exception {
UserForm userform = (UserForm) form;
String name = userform.getName();
String psw = userform.getPwd();
if ("admin".equals(name) && "admin".equals(psw))
{
System.out.print("good!");
return mapping.findForward("success");
} else
{
System.out.print("bad!");
return mapping.findForward("failed");
}
}
}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户登录</title>
</head><body>
<form id="form1" name="form1" method="post" action="login.do">
  <table width="760" border="0" cellpadding="5" cellspacing="5">
    <tr>
      <td><div align="center">用户登录</div></td>
    </tr>
    <tr>
      <td><div align="right"></div>        <div align="center">帐号
          <input type="text" name="textfield" />
        </div></td>
    </tr>
    <tr>
      <td><div align="right"></div>        <div align="center">密码
          <input type="text" name="textfield2" />
        </div></td>
    </tr>
    <tr>
      <td><div align="center">
  <input type="submit" name="Submit" value="提交" />
  &nbsp;&nbsp;
        <input type="reset" name="Submit2" value="重置" />
      </div></td>
    </tr>
    <tr><td><a href="regist.do">register</a></td></tr>
  </table>
</form>
</body>
</html>上面的是文件

解决方案 »

  1.   

    填充actionform 页面里应该用struts的标记吧.  
    如:<form .. > 应该用:<html:form action="login.do" method="post">  ..</html:form>还有 填充form的 文本框应该为:<html:text ../>  等等..
      

  2.   

    还有程序死机的吗?看看的后台肯定异常满天飞了,找原因!你一下发上来这么多的东西,也没有心情看!就是扫了一眼你的jsp,你的<form id="form1" name="form1" method="post" action="login.do">一看就不对,应该加“/”要使用struts的标签你的写法是对的!其他的没有看!先把这里该了再说!
      

  3.   

    问题解决了
    HttpServletResponse request
    这个写错了