24,922
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!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=utf-8">
<title>Insert title here</title>
</head>
<body>
<form action="register.do?methodName=register" method="post">
<table align=center border=1>
<tr> <td>name</td> <td><input type=text name=name></td> </tr>
<tr> <td>password</td> <td><input type=password name=password></td> </tr>
<tr> <td>salary</td> <td><input type=text name=salary></td> </tr>
</table>
<p align=center> <input type=submit value=提交> <input type=reset value=修改> </p>
</form>
</body>
</html>
login.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!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=utf-8">
<title>Insert title here</title>
</head>
<body>
welcome my friend!
</body>
</html>
Action
package net.apobates.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
public class Account extends DispatchAction {
public ActionForward register(ActionMapping arg0, ActionForm arg1,
HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
// TODO Auto-generated method stub
return arg0.findForward("success");
}
}
配置文件
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!-- ================================================ Form Bean Definitions -->
<form-beans>
</form-beans>
<!-- ========================================= Global Exception Definitions -->
<global-exceptions>
</global-exceptions>
<!-- =========================================== Global Forward Definitions -->
<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards>
<!-- =========================================== Action Mapping Definitions -->
<action-mappings>
<!-- Default "Welcome" action -->
<!-- Forwards to Welcome.jsp -->
<action
path="/Welcome"
forward="/pages/Welcome.jsp"/>
<action
path="/register"
parameter="methodName"
type="net.apobates.struts.Account">
<forward name="success" path="/login.jsp" />
</action>
</action-mappings>
<!-- ======================================== Message Resources Definitions -->
<message-resources parameter="MessageResources" />
</struts-config>
<action path="/windward" type="windward.action.ActionServlet"
parameter="methodName">
<forward name="tologin" path="/login.jsp" redirect="true" />
<!-- 这里如果是action的话。例如-->
<!-- <forward name="tologin" path="/login" redirect="true" /> -->
</action>
[/quote]
我用MappingDispatchAction也是不行 真实奇怪了!
我非常奇怪为什么是/project1/ is not available![/quote]
你用的struts 1.x?2.x?[/quote]
我用的是struts1.2
<action path="/windward" type="windward.action.ActionServlet"
parameter="methodName">
<forward name="tologin" path="/login.jsp" redirect="true" />
<!-- 这里如果是action的话。例如-->
<!-- <forward name="tologin" path="/login" redirect="true" /> -->
</action>
[/quote]
我用MappingDispatchAction也是不行 真实奇怪了!
我非常奇怪为什么是/project1/ is not available![/quote]
你用的struts 1.x?2.x?
<action path="/windward" type="windward.action.ActionServlet"
parameter="methodName">
<forward name="tologin" path="/login.jsp" redirect="true" />
<!-- 这里如果是action的话。例如-->
<!-- <forward name="tologin" path="/login" redirect="true" /> -->
</action>
[/quote]
我用MappingDispatchAction也是不行 真实奇怪了!
我非常奇怪为什么是/project1/ is not available!
<action path="/windward" type="windward.action.ActionServlet"
parameter="methodName">
<forward name="tologin" path="/login.jsp" redirect="true" />
<!-- 这里如果是action的话。例如-->
<!-- <forward name="tologin" path="/login" redirect="true" /> -->
</action>