zoukankan      html  css  js  c++  java
  • Struct配置

    这里只是写到配置方法:

    第一步:LoginAction:

      

    package com.inspur.actions;

    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;
    import org.springframework.web.context.WebApplicationContext;
    import org.springframework.web.context.support.WebApplicationContextUtils;

    import com.inspur.forms.*;


    public class LoginAction extends DispatchAction {
     //响应登录
      public ActionForward login(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
       System.out.println("******通过新的方式响应请求***********");
       /*
       
       EmployeeForm employeeForm=(EmployeeForm)form;
       //构建一个Employee对象
       Employee e=new Employee();
       e.setId(employeeForm.getId());
       e.setName(employeeForm.getName());
       e.setLeader(employeeForm.getLeader());
       e.setMid("111111");
       eif.addEmployee(e);
       request.getSession().setAttribute("adder", e);
       */
       return mapping.findForward("ok");
      }
      
    }

    第二步:

    <?xml version="1.0" encoding="utf-8"?>
    <!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-beans>
     <form-bean name="userForm" type="com.inspur.forms.UserForm" />
     </form-beans>
     <action-mappings>
     <action path="/login" parameter="flag" name="userForm" type="com.inspur.actions.LoginAction">
     <forward name="ok" path="/WEB-INF/welcome.jsp"/>
     <forward name="err" path="/WEB-INF/login.jsp"/> 
     </action>
     </action-mappings>
     <!-- 配置代理请求处理 DelegatingRequestProcessor ,它的用户是
     <controller>
       <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
     </controller>
      -->
    </struts-config>

  • 相关阅读:
    1、怎么通过postman创建mock服务?
    13、使用正则表达式完成添加投资项目接口
    12、登录接口实战
    11、简历编写
    下载HTMLTestRunner 地址
    selenium (二)
    python 自动化测试
    Linux 安装MySQL流程
    文件 open 方法
    面向对象知识总结
  • 原文地址:https://www.cnblogs.com/CooderIsCool/p/4720849.html
Copyright © 2011-2022 走看看