Struts2配置

1.导包

  将lib文件夹下的jar包导入到项目工程中

2.编写web.xml文件

web.xml

  <display-name>goodsmessage</display-name>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>/foolish.jsp</welcome-file>
  </welcome-file-list>
此段代码包含在<web-app></web-app>中。

3.在src下创建struts.xml文件

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
  <!-- 设置为true,当struts.xml文件更改时,不需重启tomcat -->
  <constant name="struts.devMode" value="true"/>

  <!--此处用来实现<input type="file">文件上传功能 -->
  <constant name="struts.multipart.maxSize" value="102400000"/>

  <include file="struts-default.xml"></include>
  
  <package name="Login" extends="struts-default">
    <action name="login" class="Login.AdminLoginAction">
      <result name="loginfail">/loginerror.jsp</result>
      <result name="loginsuccess">/newhome.lzw</result>
    </action>
    
    <action name="logout" class="Login.logout">
      <result name="logout">/login.jsp</result>
    </action>  
  </package>
</struts>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章