| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 976 人关注过本帖
标题:刚学struts就遇到问题
取消只看楼主 加入收藏
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
 问题点数:0 回复次数:5 
刚学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
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
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
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
hxm2005
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2005-8-11
收藏
得分:0 
试过了,还是不行,好像不认struts标签,我把页面改成和html标签了,但是页面可以出来,就是取不了页面的值,
2007-01-17 11:11
快速回复:刚学struts就遇到问题
数据加载中...
 
   



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

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