struts2 跳转

qiaoxin2006 2008-10-24 06:02:28
给位大侠帮帮忙
我做了一个假单的struts2.0的一个提交,总是No configuration found for the specified action 这个错误
这是SayHello.jsp 页面
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Say Hello</title>
</head>
<body>
<h3>Say "Hello" to: </h3>
<s:form name="HelloWorld" action="HelloWorld" namespace="/example">
Name: <s:textfield name="name" />
<s:submit></s:submit>
</s:form>
</body>
</html>
这是HelloWorld.jsp页面
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hello</title>
</head>
<body>
<h3><s:property value="name" /></h3>
</body>
</html>
这是HelloWorld.java

package tutorial;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorld extends ActionSupport {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
System.out.println(name);
this.name = name;
}

public String execute()throws Exception {
name = "Hello, " + name + "!";
System.out.println(name);
return SUCCESS;
}
}
这是配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<include file="struts-default.xml"/>
<package name="tutorialone" extends="struts-default" namespace="/example">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>HelloWorld.jsp</result>
</action>
</package>
</struts>

请各位大侠帮帮忙吧
...全文
196 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
luats 2008-10-28
  • 打赏
  • 举报
回复
反正注意的问题就是那么多...不可能把我的代码贴上去还有错吧!
qiaoxin2006 2008-10-27
  • 打赏
  • 举报
回复
大哥 这招不灵啊
luats 2008-10-25
  • 打赏
  • 举报
回复
要学会看错误信息,配置问题肯定是你的xml出问题了,要么是web.xml,要么是struts.xml。不用看别处。。。绝对是那个地方你写错了
luats 2008-10-25
  • 打赏
  • 举报
回复
我把你代码的那个包名去掉了.运行一次通过....代码如下
这是SayHello.jsp 页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>Say "Hello" to: </h3>
<s:form name="HelloWorld" action="HelloWorld">
Name: <s:textfield name="name" />
<s:submit> </s:submit>
</s:form>

</body>
</html>

这是HelloWorld.jsp页面
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hello </title>
</head>
<body>
<h3> <s:property value="name" /> </h3>
</body>
</html>

这是tutorial.java

package tutorial;

import com.opensymphony.xwork2.ActionSupport;

public class tutorial extends ActionSupport {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
System.out.println(name);
this.name = name;
}

public String execute()throws Exception {
name = "Hello, " + name + "!";
System.out.println(name);
return SUCCESS;
}

}
这是配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="/struts-default.xml"></include>




<package name="tutorialone" extends="struts-default">
<action name="HelloWorld" class="tutorial.tutorial">
<result>HelloWorld.jsp </result>
</action>
</package>

</struts>
luats 2008-10-24
  • 打赏
  • 举报
回复
你的web。xml里面配置没,你的struts.xml有没有放错位置啊!我帮你调试看看

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧