我想通过action把参数从一个页面传到另一个页面上,但总是出现404错误,到底是怎么回事啊!我检查N遍配置文件了 都没有错,还请高手指点一下:
struts.xml://struts.xml是放在class目录下,还是放在src目录下呢?我放到了class目录下面
<?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="test" extends="struts-default">
<action name="hello" class="test.Hello">
<result>result.jsp</result>
</action>
</package>
</struts>PostP.jsp //用于用户输入信息
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>To past paramter</title>
</head>
<body>
<h2>please input you name:</h2>
<form action="hello.action" method="post">
<input type="text" name="name"></input><br></br>"
<input type="submit" value="submit" align="right"/><input type="reset" value="reset"align="left"></form>
</body>
</html>
result.jsp://用于显示参数的页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>come to the result</title>
</head>
<body>
<h2>Hello to you!</h2>
${name}
</body>
</html>
Hello.action:
package test;import com.opensymphony.xwork2.ActionSupport;@SuppressWarnings("serial")
public class Hello extends ActionSupport {
private String name; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
}
public String execute(){
return "success";
}
}
请高手给予指导:我是在哪里出错了,为何会出现这种错误,迫切渴望得到答案
struts.xml://struts.xml是放在class目录下,还是放在src目录下呢?我放到了class目录下面
<?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="test" extends="struts-default">
<action name="hello" class="test.Hello">
<result>result.jsp</result>
</action>
</package>
</struts>PostP.jsp //用于用户输入信息
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>To past paramter</title>
</head>
<body>
<h2>please input you name:</h2>
<form action="hello.action" method="post">
<input type="text" name="name"></input><br></br>"
<input type="submit" value="submit" align="right"/><input type="reset" value="reset"align="left"></form>
</body>
</html>
result.jsp://用于显示参数的页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>come to the result</title>
</head>
<body>
<h2>Hello to you!</h2>
${name}
</body>
</html>
Hello.action:
package test;import com.opensymphony.xwork2.ActionSupport;@SuppressWarnings("serial")
public class Hello extends ActionSupport {
private String name; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
}
public String execute(){
return "success";
}
}
请高手给予指导:我是在哪里出错了,为何会出现这种错误,迫切渴望得到答案
解决方案 »
- java 开发四年。
- 关于HighCharts在Java环境下的导出方法~有了解的么
- spring 注解bean时,如何定义scope?
- java程序
- underlying method这个怎么翻译
- 关于wsad5.1报的错的问题
- jdo中可以通过配置xml文件来映射数据库表,请问也同样可以映射存储过程么?如果可以,请给个例子,谢谢
- 刚发工资,AC米兰夺冠,今天生日,过一会儿和PLMM吃饭.散分喽!
- Spring + SpringMVC + JPA(Hibernate)集成环境持久化问题
- java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this w
- JAVA读取数据库生成XML文件
- java ssh 保存数据问题? 急 在线等待....
我是习惯丢在src下面,打开快,class需要好几层 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:/applicationContext.xml,
classpath*:/applicationContext_*.xml
</param-value>
</context-param>
There is no Action mapped for namespace / and action
是配置的错误,找不到
WEB-INF\classes
这个文件的目录里面
视频下载地址:http://download.csdn.net/detail/zudajun225/3581893