Struts1配置
简单写下Struts1配置过程:
1.导入必须的jar包,最少包括commons-beanutils.jar,common-digester.jar,common-logging.jar,struts.jar。
?
2.配置文件web.xml注册Struts1的servlet、配置文件名及路径、接收路径格式。
?
3.配置文件struts-config.xml,包括必要的formbeans(可无),action,forward。
?
4.写自己的action。
?
?
PS:文件如下:
1.web.xml
?
?2.struts-config.xml
??
3.TestAction
package com.tim.struts.action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;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 TestAction extends Action {@Overridepublic ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception {System.out.println("!!");return mapping.findForward("success");}}?4.对应jar包(struts1.2)
见附件。
5.访问路径,http://localhost:8888/工程名/test.do(也可配置域名访问)
?