日期:2014-05-20 浏览次数:21100 次
<form id="form1" name="login" method="post" action="/LoginAction.do?method=Login">
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>Login.jsp</welcome-file> </welcome-file-list> </web-app>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources></data-sources> <global-exceptions></global-exceptions> <global-forwards></global-forwards> <action-mappings> <action path="/LoginAction" type="com.dsxx.Action.LoginAction" parameter="method"> <forward name="loginsuccess" path="/index.jsp"></forward> <forward name="loginfail" path="/fail.html"></forward> </action> </action-mappings> </struts-config>
package com.dsxx.Action; import javax.servlet.http.*; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; public class LoginAction extends Action{ public ActionForward Login( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ ActionForward forward=new ActionForward(); forward=mapping.findForward("loginfail"); return forward; } }