struts2 action跳转出现404 5
以下为部分代码----->web.xml<display-name>2018_4_16</display-name><filter><filter-name>struts...
以下为部分代码
----->web.xml
<display-name>2018_4_16</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- END SNIPPET: filter -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
----->struts.xml
<struts>
<!-- Overwrite Convention -->
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-showcase"/>
<constant name="struts.convention.package.locators" value="example"/>
<package name="helloWorld" extends="struts-default" namespace="/">
<action name="hello" class="com.demo.HelloAction" method="execute">
<result name="success">/hello.jsp</result>
</action>
</package>
----->.java
package com.demo;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport{
private String name;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("22222222222222222222222222");
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
------>hello.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
------index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="hello" method="post">
<H3>输入你的名字</H3>
<input type="text" name ="name">
<input type="submit" value="HEY">
</form>
</body>
</html> 展开
----->web.xml
<display-name>2018_4_16</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- END SNIPPET: filter -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
----->struts.xml
<struts>
<!-- Overwrite Convention -->
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-showcase"/>
<constant name="struts.convention.package.locators" value="example"/>
<package name="helloWorld" extends="struts-default" namespace="/">
<action name="hello" class="com.demo.HelloAction" method="execute">
<result name="success">/hello.jsp</result>
</action>
</package>
----->.java
package com.demo;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport{
private String name;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("22222222222222222222222222");
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
------>hello.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
------index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="hello" method="post">
<H3>输入你的名字</H3>
<input type="text" name ="name">
<input type="submit" value="HEY">
</form>
</body>
</html> 展开
2018-04-20
展开全部
你这<form action="hello" method="post"> 你确定进去该方法了么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询