| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 976 人关注过本帖
标题:刚学struts就遇到问题
只看楼主 加入收藏
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
 问题点数:0 回复次数:10 
刚学struts就遇到问题

刚学struts就遇到问题,那位高手能给我看看,在线等
+++++++++++++++++++++++++++++++++++++++++++++++++++++
报的错误
HTTP Status 500 -

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

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot retrieve mapping for action /HelloWordAction
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.HelloWord_jsp._jspService(HelloWord_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: Cannot retrieve mapping for action /HelloWordAction
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:810)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
org.apache.jsp.HelloWord_jsp._jspx_meth_html_form_0(HelloWord_jsp.java:120)
org.apache.jsp.HelloWord_jsp._jspService(HelloWord_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
+++++++++++++++++++++++++++++++++++++++++++++++++++++
页面
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<%@ page language="java" pageEncoding="GB2312" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<jsp:useBean id="HelloWordForme"class="web.form.HelloWordForm"scope="page"/>
<html>
<head>
<title> Hello Word </title>
</head>
<body>
<html:form action="/HelloWordAction"method="post">
请输入:Hello Word:<html:text property="word"/><html:submit/>
</html:form>
<br>
+++++++++++++++++++++++++++++++++++++++++++++++++++++
config中配置
<?xml version="1.0" ?>
<!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>
<form-beans>
<form-bean name="HelloWordForm" type="web.form.HelloWordForm"/>

</form-beans>
<global-exceptions/>

<global-forwards/>
<action-mappings>
<action path = "/HelloWordAction"
type= "web.action.HelloWordAction"
name="HolloWordForm"
validate="false"
scope="session"
>
<forward name="success" path="/index.jsp"/>
</action>
</action-mappings>
<controller/>

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


<bean:write name="HelloWordForme" scope="session" property="word"/>
</body>
</html>

搜索更多相关主题的帖子: struts 
2007-01-16 15:45
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 

action 和form的代码呢?


win32汇编
病毒 加密
目前兴趣所在
2007-01-16 16:22
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
得分:0 
[CODE][QUOTE]

action内容
package web.action;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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 class HelloWordAction extends Action {
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)

throws Exception
{
return mapping.findForward("success");
}
}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

2007-01-16 16:37
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 
你的配置文档怎么写到页面里面去了??

win32汇编
病毒 加密
目前兴趣所在
2007-01-16 16:47
疯子java
Rank: 4
等 级:贵宾
威 望:13
帖 子:328
专家分:0
注 册:2004-9-19
收藏
得分:0 
<html:form action="/HelloWordAction"method="post">
请输入:Hello Word:<html:text property="word"/><html:submit/>
</html:form>

注意你的HelloWordAction这个是什么,这里应该使用HelloWordAction。do之类的

请查看Struts的相关文档


疯言疯语 疯部可及 ---世界法第1章第1节第1条规定 此人由于说话太过于疯!!!其余人等切不可与其交谈! 此人由于说话太过于疯!!!此人的话100%的不能相信
2007-01-16 17:09
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
得分:0 
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<%@ page language="java" pageEncoding="GB2312" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<jsp:useBean id="HelloWordForme"class="web.form.HelloWordForm"scope="page"/>
<html>
<head>
<title> Hello Word </title>
</head>
<body>
<html:form action="HelloWordAction.do"method="post">
请输入:Hello Word:<html:text property="word"/><html:submit/>
</html:form>
<br>
<bean:write name="HelloWordForme" scope="session" property="word"/>
</body>
</html>
换成这个也是又错误
2007-01-16 17:30
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
得分:0 

form在者
import org.apache.struts.action.ActionForm;

public class HelloWordForm extends ActionForm{

String word="";

/**
* @return 返回 word。
*/
public String getWord() {
return word;
}
/**
* @param word 要设置的 word。
*/
public void setWord(String word ) {
this.word=word;
}
}

2007-01-16 17:33
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 
是不是没配置web.xml啊

win32汇编
病毒 加密
目前兴趣所在
2007-01-16 17:41
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
得分:0 

web-xml:
<?xml version="1.0" encoding="UTF-8"?>


<web-app>
<display-name>HelloApp Struts Application</display-name>

<!-- Standard Action Servlet Configuration -->
<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>
<load-on-startup>2</load-on-startup>
</servlet>

<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>HelloWord.jsp</welcome-file>
</welcome-file-list>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

</web-app>

2007-01-17 08:58
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
收藏
得分:0 
<html:form action="/HelloWordAction.do"method="post">
试试

win32汇编
病毒 加密
目前兴趣所在
2007-01-17 09:11
快速回复:刚学struts就遇到问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018928 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved