5.MyMVC Framework 配置文件XML Schema文件mymvc.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://closer1984.blog.edu.cn/MyMVC"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://closer1984.blog.edu.cn/MyMVC">
<xsd:element name="mymvc">
<xsd:complexType>
<xsd:sequence maxOccurs="1" minOccurs="1">
<xsd:element name="action-mapping"
maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence maxOccurs="1">
<xsd:element name="path" type="xsd:string" />
<xsd:element name="type" type="xsd:string" />
<xsd:element name="form" maxOccurs="1">
<xsd:complexType>
<xsd:sequence maxOccurs="1">
<xsd:element name="form-name"
type="xsd:string"/>
<xsd:element name="form-class"
type="xsd:string" />
<xsd:element name="scope"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="forwards" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="forward" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence >
<xsd:element
name="forward-name" type="xsd:string" />
<xsd:element
name="forward-path" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
6.MyMVC Framework配置文件mymvc.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- 本文件是示例配置,供参考 -->
<mymvc xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://closer1984.blog.edu.cn/MyMVC" xsi:schemaLocation="http://closer1984.blog.edu.cn/MyMVC mymvc.xsd">
<!-- 配置操作映射 -->
<action-mapping>
<!-- 请求路径 -->
<path>/login.do</path>
<type>com.mymvc.action.LoginAction</type>
<!-- 表单 -->
<form>
<form-name>loginBean</form-name>
<form-class>com.mymvc.service.UserBean</form-class>
<scope>request</scope>
</form>
<!-- 页面跳转集合 -->
<forwards>
<forward>
<forward-name>home</forward-name>
<forward-path>/index.jsp</forward-path>
</forward>
<forward>
<forward-name>show</forward-name>
<forward-path>/show.jsp</forward-path>
</forward>
<forward>
<forward-name>error</forward-name>
<forward-path>/error.jsp</forward-path>
</forward>
</forwards>
</action-mapping>
</mymvc>
7.基于MyMVC Framework开发web程序时的基本配置:
在web.xml中配置核心控制器:
<servlet>
<servlet-name>CenterController</servlet-name>
<servlet-class>com.mymvc.action.CenterController</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/mymvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CenterController</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>