利用struts2进行页面的跳转,但是一直提示404无法找到路径,而且路径正确,是不是jar包的问题 5
jsp页面:<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%><%@tagliburi="/st...
jsp页面:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<s:form action="personAction" method="post">
<input type="submit">
</s:form>
</body>
</html>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
、struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<package name="person" namespace="/person" extends="struts-default">
<action name="personAction" class="personAction">
<result name="success">
/success.jsp
</result>
</action>
</package>
</struts>
action:
import com.opensymphony.xwork2.ActionSupport;
public class personAction extends ActionSupport{
public String login() {
return "success";
}
@Override
public String execute() {
return "success";
}
} 展开
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<s:form action="personAction" method="post">
<input type="submit">
</s:form>
</body>
</html>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
、struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<package name="person" namespace="/person" extends="struts-default">
<action name="personAction" class="personAction">
<result name="success">
/success.jsp
</result>
</action>
</package>
</struts>
action:
import com.opensymphony.xwork2.ActionSupport;
public class personAction extends ActionSupport{
public String login() {
return "success";
}
@Override
public String execute() {
return "success";
}
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏5(财富值+成长值)
3个回答
展开全部
你from 表单的action ,不用加后缀名的嘛? .action ?
更多追问追答
追问
用的struts标签,会自动加.action 不加也对啊,struts2默认的就是.action
或者是空
追答
你的action 的package :
namespse 有值了,所以你的action 要写上:/person/personAction
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你试试把那个namespace中的person去掉!
追问
namespace去掉了,但是路径
还是提示无效
我怀疑的我jar包少道了,但查询一下对啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
嗯哼,,可以拿。
追问
???????什么意思
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询