struts2配置jar包以及struts.xml常用配置

struts2配置需要的jar包:

  1. http://struts.apache.org/下载struts2.x完整的压缩包
  2. 解压该压缩包,将apps下的struts2-blank.war(就是一个压缩包)解压
  3. lib下的jar包就是struts2运行需要的jar包

在web.xml中配置struts2的拦截器

<filter>
    <filter-name>struts2filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
filter>
<filter-mapping>
        <filter-name>struts2filter-name>
        <url-pattern>/*url-pattern>
filter-mapping>

struts2核心配置文件struts.xml常用配置



<struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
    <package name="default" namespace="/" extends="struts-default">
        <action name="Test1" class="com.mrw.Test1.Test1" method="execute">
            <result name="success">/hello.jspresult>
        action>
    package>
    
      <include file="struts1.xml">include>
      
      <package name="student" namespace="/StuOpera" extends="struts-default">
        <action name="stu_*" class="com.mrw.Test1.Stu{1}" method="{1}">
            <result name="success">/hello.jspresult>
        action> 
    package>
    
struts> 

你可能感兴趣的:(struts2)