<?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>
	<!-- 在此注册ActionForm -->
  <form-beans>
  	<!-- name:名称 	type:类路径 -->
  	<form-bean name="queryForm" type="com.yourcompany.struts.QueryForm"></form-bean>
  </form-beans>
  <global-exceptions />
  <!-- 设置URL逻辑名称(全局,任意的Action都可以识别到) -->
  <global-forwards />
  <!-- 注册Action -->
  <action-mappings>
  <!-- type:类路径   	name:相应的ActionForm的名称	path:客户端提交到服务器时指定的路径 -->
  <action name="queryForm" path="/query" type="com.yourcompany.struts.QueryAction"></action>
  
  </action-mappings>
  
  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>
web.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>Prj2_1</display-name>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
</web-app>

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐