`

Struts的基本配置

阅读更多
这个是web.xml的基本配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
  <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>
 
</web-app>


这个是Struts2.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>
<constant name="struts.devMode" value="true" />
<!-- 上面是常量的开发模式 -->
<package name="default" namespace="/" extends="struts-default">
          <!-- 如果路径都不精确的,找namespace为空的 ,name和namespace最好一样的名字 -->
        <action name="hello" class="action.IndexAction" method="check">
            <result name="success">/login.jsp</result>
        </action>
    </package>
    <!-- Add packages here -->

</struts>


这个是通配符的基本配置,1,表示第一个星号

<struts>
<constant name="struts.devMode" value="true" />
<!-- 上面是常量的开发模式 -->
<package name="default" namespace="/" extends="struts-default">
          <!-- 如果路径都不精确的,找namespace为空的 ,name和namespace最好一样的名字 -->
        <action name="hello*" class="action.IndexAction" method="{1}">
            <result name="success">/{1}login.jsp</result>
        </action>
    </package>
    <!-- Add packages here -->

</struts>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics