iteye_4746 2009-05-31 20:36
浏览 336
已采纳

struts自动生成的action form jsp 和自己创建的 一点小问题

小弟 通过myeclipse自动生成的struts的action form jsp 写了一个简单的login 成功
然后想不通过form 只用action 和jsp 重新写个login 一直出错 请知道的朋友解答下
多谢!!!!
代码如下
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <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>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

structs-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
  <form-beans >
    <form-bean name="aaaaForm" type="org.apache.struts.validator.DynaValidatorActionForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards >
    <forward
      name="success"
      path="/success.jsp"
      redirect="true" />
    <forward
      name="failed"
      path="/failed.jsp"
      redirect="true" />

  </global-forwards>

  <action-mappings >
    <action
      attribute="aaaaForm"
      input="/form/aaaa.jsp"
      name="aaaaForm"
      path="/aaaa"
      scope="request"
      type="com.yourcompany.struts.action.AaaaAction" />

  </action-mappings>

  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>

jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'aaaa.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">   
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
 
  <body>
  <form action ="/aaaa">
  name :<input type ="text" name="name">
  password :<input type ="password" name ="password">
  <input type="submit" value="wahaha">
 
  </form>
  
  </body>
</html>

action
public class AaaaAction extends Action {
/*
* Generated Methods
/

/
*
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {

if(request.getParameter("name").equals("aaa")&&request.getParameter("password").equals("123")){
return mapping.findForward("success");
}
else
return mapping.findForward("failed");
}
}
多谢了!!!
问题补充:
错误信息 :
输入 用户名和密码后的
HTTP Status 404 - /aaaa

--------------------------------------------------------------------------------

type Status report

message /aaaa

description The requested resource (/aaaa) is not available.


问题补充:
success.jsp failed.jsp
都建了
问题补充:
恩 和INDEX.JSP一个位置
问题补充:
我追踪了 好像不经过action
问题补充:
没有 加我QQ63913838这样太慢了 多谢!!

  • 写回答

5条回答 默认 最新

  • yangkaikai 2009-06-01 15:55
    关注

    tomcat启动的时候没有错误么

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘