Struts复习心得

来源:互联网 发布:淘宝怎么一键上传宝贝 编辑:程序博客网 时间:2024/05/21 14:07

 好久不用纯粹的struts了,今天看了看

发现主要是struts-config.xml的修改;

<?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 />
  <form-beans >

//定义form
    <form-bean name="userForm" type="com.yourcompany.struts.form.UserForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards >
     ///存放全局的跳转

  </global-forwards>

  <action-mappings >
    <action
      attribute="userForm"
      input="/index.jsp"
      name="userForm"
      parameter="method"
      path="/user"
      scope="request"
      type="com.yourcompany.struts.action.UserAction" >
      <forward name="next" path="/next.jsp"></forward>
      </action>
  </action-mappings>

  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>

编写form类要继承ActionForm

编写action类要继承DispatchAction

通过BeanUtils类转换form和VO;

原创粉丝点击