XML建模

目录一、学会XML建模二、23种建模方式之工厂模式三、练习案例今天我们来看看如何XML建模,首先还是先把建模的XML文件【config.xml】放在这里: 我们先来分析一下这个xml文件:根据上面分析我们可以知道此配置文件一共有三个不同的标签:config:有子标签、没有属性action:有子标签forward:没有子标签ForwardModel:ActionModel:有子标签,需要两个行为方法: 1)添加forward标签
摘要由CSDN通过智能技术生成

目录

一、学会XML建模

二、23种建模方式之工厂模式

三、练习案例


一、学会XML建模

今天我们来看看如何XML建模,首先还是先把建模的XML文件【config.xml放在这里:

<?xml version="1.0" encoding="UTF-8"?>

<config>
	<action path="/regAction" type="test.RegAction">
		<forward name="failed" path="/reg.jsp" redirect="false" />
		<forward name="success" path="/login.jsp" redirect="true" />
	</action>

	<action path="/loginAction" type="test.LoginAction">
		<forward name="failed" path="/login.jsp" redirect="false" />
		<forward name="success" path="/main.jsp" redirect="true" />
	</action>
</config>

 我们先来分析一下这个xml文件:

1) 分析标签

一个根标签:config

一个子标签:action

action内有子标签:forward

2) 分析属性

action:path、type

forward:name、path、redirect

根据上面分析我们可以知道此配置文件一共有三个不同的标签:

config:有子标签、没有属性

action:有子标签

forward:没有子标签

因此我们开始我们建模的第一步

利用面向对象编程思想分别为不同的标签建设实体类

ForwardModel:

package com.leaf.mode;
/**
 * forward标签
 * @author Leaf
 *
 * 2022年6月15日 上午8:40:48
 */
public class ForwardModel {
	//<forward name="success" path="/main.jsp" redirect="true" />
	private String name;
	private String path;
	private boolean redirect;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
	}
	public boolean isRedirect() {
		return redirect;
	}
	public void setRedirect(boolean redirect) {
		this.redirect = redirect;
	}
	
	public ForwardModel() {

	}
	public ForwardModel(String name, String path, boolean redirect) {
		this.name = name;
		this.path = path;
		this.redirect = redirect;
	}
	
	@Override
	public String toString() {
		return "ForwardMode [name=" + name + ", path=" + path + ", redirect=" + redirect +
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_Leaf1217

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值