摘自http://blog.csdn.net/qq_18989901/article/details/52403737

 GridBagLayout的用法

GridBagLayout是面板设计中最复杂的布局工具,当然用的好的话也是最方便的。

GridBagLayout其组件的摆放都是有GridBagConstraints控制的。可以将需要设计的界面划分成许多个纵横的小网格,每个网格里面最多放置一个组件,一个组件可以占用多个网格。

网格的定义是由gridx和gridy定义的,前者表示横坐标,后者表示纵坐标,坐标是从0开始,从整个面板的左上角开始算起,所以在上图中,按钮7所在的位置gridx=0,gridy=0;以此类推,后面所有的网格位置都可以这样定义;

但是图中网格的宽度和高度是由什么定义的呢?答案是gridwidth和gridheight,为1表示占用一个网格,为2表示占用两个网格,如上图中"+"的gridwidth=1,gridheight=2;

知道这两个,就可以大体把网格划分清楚,每一个的具体位置也就有了着落。有朋友会说,我也是这样写的,但是组件怎么就那么小呢?那是因为GridBaglayout里面还有一项参数weight,她控制着组件随着面板的变化自身的变化情况,默认情况下weightx=0,weighty=0,意思是组件大小固定,不管面板如何变,自身就那么大,但是如果想让组件随面板变化的话,可以设置weightx和weighty,设置为浮点数也行,其值代表着变化的大小,也就是你宽度设为2,高度设为1的话,拉大面板会使组件越变越宽。

这三个是比较重要的Constraints,另外,还有insets,其有四个参数,表示其上左下右和相邻组件的最小间隔;ipadx和ipady表示组件间距,默认是0(其和insets不同读者可以自己摸索一下);fill参数表示当网格区域比组件大的伤害,组件是以何种方式填充区域,是全方位还是水平或竖直;anchor是区域比组件大时,组件应该显示在区域的哪个方位,西北还是东南;

测试1:

本文主要通过设计一个计算器界面的方式,来学习GridBagLayout的使用。最终的效果如下图所示:

下面是我实现面板显示部分的所有代码:

 package com.wst.bj;

 import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField; public class GridBagTest2 { private JFrame jframe = new JFrame();
private JButton bt1 = new JButton("1");
private JButton bt2 = new JButton("2");
private JButton bt3 = new JButton("3");
private JButton bt4 = new JButton("4");
private JButton bt5 = new JButton("5");
private JButton bt6 = new JButton("6");
private JButton bt7 = new JButton("7");
private JButton bt8 = new JButton("8");
private JButton bt9 = new JButton("9");
private JButton bt0 = new JButton("0");
private JButton btdot = new JButton(".");
private JButton btsignleft = new JButton("(");
private JButton btsignright = new JButton(")");
private JButton btp = new JButton("+");
private JButton btm = new JButton("-");
private JButton btmp = new JButton("*");
private JButton btd = new JButton("/");
private JButton bte = new JButton("=");
private JButton bt = new JButton("00");
private JButton btclear = new JButton("cl");
private JTextField textField = new JTextField(); public GridBagTest2() {
init();
} private void init()
{
FrameUtil.initFram(jframe, 300, 400);
JPanel jpanel = createPanel();
jframe.add(jpanel);
} private JPanel createPanel(){
JPanel panel = new JPanel(); GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbs = new GridBagConstraints();
panel.setLayout(gbl); panel.add(bt7);panel.add(bt8);panel.add(bt9);panel.add(btp);
panel.add(bt4);panel.add(bt5);panel.add(bt6);
// panel.add(bt1);panel.add(bt2);panel.add(bt9);panel.add(btp);
panel.add(bt1);panel.add(bt2);panel.add(bt3);panel.add(btm);
panel.add(bt0);panel.add(btdot);
panel.add(btsignleft);panel.add(btsignright);panel.add(bte);panel.add(btmp);
panel.add(btclear);panel.add(bt); panel.add(btd);
panel.add(textField); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=0;
gbl.setConstraints(bt7, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=0;
gbl.setConstraints(bt8, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=0;
gbl.setConstraints(bt9, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=2;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=0;
gbl.setConstraints(btp, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=1;
gbl.setConstraints(bt4, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=1;
gbl.setConstraints(bt5, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=1;
gbl.setConstraints(bt6, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=2;
gbl.setConstraints(bt1, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=2;
gbl.setConstraints(bt2, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=2;
gbl.setConstraints(bt3, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=2;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=2;
gbl.setConstraints(btm, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=2;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=3;
gbl.setConstraints(bt0, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=3;
gbl.setConstraints(btdot, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=4;
gbl.setConstraints(btsignleft, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=4;
gbl.setConstraints(btsignright, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=2;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=4;
gbl.setConstraints(bte, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=4;
gbl.setConstraints(btmp, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=5;
gbl.setConstraints(btclear, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=5;
gbl.setConstraints(bt, gbs);
gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=5;
gbl.setConstraints(btd, gbs); gbs.fill=GridBagConstraints.BOTH;gbs.gridwidth=4;gbs.gridheight=3;
gbs.insets=new Insets(5, 5, 5, 5);gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=6;
gbl.setConstraints(textField, gbs); return panel;
}
}

测试2:

 package com.wst.bj;

 import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField; public class GridBagTest4 { private JFrame jframe = new JFrame();
private JButton bt1 = new JButton("1");
private JButton bt2 = new JButton("2");
private JButton bt3 = new JButton("3");
private JButton bt4 = new JButton("4");
private JButton bt5 = new JButton("5");
private JButton bt6 = new JButton("6");
private JButton bt7 = new JButton("7");
private JButton bt8 = new JButton("8");
private JButton bt9 = new JButton("9");
private JButton bt0 = new JButton("0");
private JButton btdot = new JButton(".");
private JButton btsignleft = new JButton("(");
private JButton btsignright = new JButton(")");
private JButton btp = new JButton("+");
private JButton btm = new JButton("-");
private JButton btmp = new JButton("*");
private JButton btd = new JButton("/");
private JButton bte = new JButton("=");
private JButton bt = new JButton("00");
private JButton btclear = new JButton("cl");
private JTextField textField = new JTextField(); public GridBagTest4() {
init();
} private void init()
{
FrameUtil.initFram(jframe, 300, 400);
JPanel jpanel = createPanel();
jframe.add(jpanel);
} private JPanel createPanel(){
JPanel panel = new JPanel(); GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbs = new GridBagConstraints();
panel.setLayout(gbl); panel.add(bt7);panel.add(bt8);panel.add(bt9);panel.add(btp);
panel.add(bt4);panel.add(bt5);panel.add(bt6);
panel.add(bt1);panel.add(bt2);panel.add(bt3);panel.add(btm);
panel.add(bt0);panel.add(btdot);
panel.add(btsignleft);panel.add(btsignright);panel.add(bte);panel.add(btmp);
panel.add(btclear);panel.add(bt); panel.add(btd);
panel.add(textField); gbs.fill=GridBagConstraints.NONE;
// gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.ipadx = 100;
// gbs.ipady = 100;
gbs.anchor = GridBagConstraints.WEST;
gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=0;
gbl.setConstraints(bt7, gbs); gbs.fill=GridBagConstraints.NONE;
// gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.NORTHEAST;
gbs.gridx=1;gbs.gridy=0;
gbl.setConstraints(bt8, gbs); gbs.fill=GridBagConstraints.NONE;
// gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.SOUTH;
gbs.gridx=2;gbs.gridy=0;
gbl.setConstraints(bt9, gbs);
//
gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=2;
//// gbs.insets=new Insets(5, 5, 5, 5);
//// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=0;
gbl.setConstraints(btp, gbs);
// =====================================================
gbs.fill=GridBagConstraints.VERTICAL;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.WEST;
gbs.gridx=0;gbs.gridy=1;
gbl.setConstraints(bt4, gbs);
//
gbs.fill=GridBagConstraints.VERTICAL;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.SOUTHEAST;
gbs.gridx=1;gbs.gridy=1;
gbl.setConstraints(bt5, gbs); gbs.fill=GridBagConstraints.VERTICAL;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.CENTER;
gbs.gridx=2;gbs.gridy=1;
gbl.setConstraints(bt6, gbs);
// =====================================================
gbs.fill=GridBagConstraints.HORIZONTAL;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.NORTH;
gbs.gridx=0;gbs.gridy=2;
gbl.setConstraints(bt1, gbs); gbs.fill=GridBagConstraints.HORIZONTAL;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.SOUTHEAST;
gbs.gridx=1;gbs.gridy=2;
gbl.setConstraints(bt2, gbs); gbs.fill=GridBagConstraints.HORIZONTAL;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.CENTER;
gbs.gridx=2;gbs.gridy=2;
gbl.setConstraints(bt3, gbs); gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=2;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=2;
gbl.setConstraints(btm, gbs);
// =====================================================
gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=2;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=3;
gbl.setConstraints(bt0, gbs); gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=3;
gbl.setConstraints(btdot, gbs);
// =====================================================
gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=4;
gbl.setConstraints(btsignleft, gbs); gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=1;
gbs.insets=new Insets(7, 7, 2, 2);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=4;
gbl.setConstraints(btsignright, gbs); gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=2;
gbs.insets=new Insets(0, 0, 0, 0);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=2;gbs.gridy=4;
gbl.setConstraints(bte, gbs); gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=3;gbs.gridy=4;
gbl.setConstraints(btmp, gbs);
// =====================================================
gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
gbs.weightx=0;gbs.weighty=0;
gbs.gridx=0;gbs.gridy=5;
gbl.setConstraints(btclear, gbs); gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.gridx=1;gbs.gridy=5;
gbl.setConstraints(bt, gbs); gbs.fill=GridBagConstraints.NONE;
gbs.gridwidth=1;gbs.gridheight=1;
// gbs.insets=new Insets(5, 5, 5, 5);
// gbs.weightx=1;gbs.weighty=1;
gbs.anchor = GridBagConstraints.EAST;
gbs.gridx=3;gbs.gridy=5;
gbl.setConstraints(btd, gbs);
// =====================================================
gbs.fill=GridBagConstraints.BOTH;
gbs.gridwidth=4;gbs.gridheight=3;
// gbs.insets=new Insets(5, 5, 5, 5);
gbs.weightx=1;gbs.weighty=1;
gbs.gridx=0;gbs.gridy=6;
gbl.setConstraints(textField, gbs);
// // =====================================================
gbs.anchor = GridBagConstraints.NORTH;
return panel;
}
}

GridBagLayout练习的更多相关文章

  1. Java GridBagLayout 简单使用

    这里只介绍了很基础布局构建及使用,主要是关于 GridBagLayout. 首先整套流程大概是, 声明一个 GridBagLayout 对象 private GridBagLayout gridBag ...

  2. Java基础之创建窗口——使用GridBagLayout管理器(TryGridBagLayout)

    控制台程序. java.awt.GridBagLayout管理器比前面介绍的其他布局管理器灵活得多,因此使用起来也比较复杂.基本机制就是在随意的矩形网格中布局组件,但网格的行和列不一定拥有相同的高度和 ...

  3. 关于GridBagLayout的讲解哦

    13-08-29 17:01:10|  分类: Java |  标签:gridbaglayout  gridbagconstraints  添加方法  |字号 订阅     GridBagLayout ...

  4. GridBagLayout()的使用方法

    GridBagLayout是java里面最重要的布局管理器之一,可以做出很复杂的布局,可以说GridBagLayout是必须要学好的的, GridBagLayout 类是一个灵活的布局管理器,它不要求 ...

  5. GridBagLayout:网格包布局管理器

    GridBagLayout:网格包布局管理器   GridBagLayout可以说是布局管理器Layout中最复杂的一个,其中涉及到的参数也比较得多,比如说: GridBagConstraints g ...

  6. GridBagLayout占多行效果注意

    如果想要出现按钮2占两行的效果,必须按键3.按钮4同时存在且同时可见. 如果缺少按钮4,则按钮2不会占两行: 如果缺少按钮3.4,则按钮2也不会占两行. package com.wst.bj; imp ...

  7. javax.Swing 使用GridBagLayout的程序栗子

    摘自https://zhidao.baidu.com/question/110748776.html javax.Swing 使用GridBagLayout的程序栗子 总共两个文件,第一个是启动文件, ...

  8. 使用GridBagLayout控制行列的高度和宽度

    摘自http://bbs.csdn.net/topics/340189065使用GridBagLayout控制行列的高度和宽度 gridwidth 指定组件显示区域的某一行中的单元格数. 默认值1,水 ...

  9. Java 的布局管理器GridBagLayout的使用方法(转)

    GridBagLayout是java里面最重要的布局管理器之一,可以做出很复杂的布局,可以说GridBagLayout是必须要学好的的, GridBagLayout 类是一个灵活的布局管理器,它不要求 ...

随机推荐

  1. pyqt 动态显示时间方法例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys,datetime from PyQt4.QtC ...

  2. web前端之 CSS引入第三方插件

    引入第三方图标插件 - fontawesome 官网地址:http://fontawesome.io/ 1.下载图标插件包 下载地址:https://codeload.github.com/FortA ...

  3. 关于safari上的select宽高问题小技,自定义下拉框

    之前一直用windows做开发,最近换了个mac,在几经折腾之下,安装完了各种开发工具,IDE等,然后欣然打开自己正在开发的网站.突然发现mac上所有的下拉框都变了,都是默认样式,无论padding, ...

  4. 期望dp-hdu-4336-Card Collector

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4336 题目大意: 有n种卡片,每包中至多有一种卡片,概率分别为p1,p2,...pn,可能有的没有卡 ...

  5. JSP九大内置对象和四种属性范围解读

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文首先主要解说了JSP中四种属性范围的概念.用法与实例. 然后在这个基础之上又引入了九 ...

  6. 设置 git config 的一些默认配置

    设置 git status的颜色. git config --global color.status auto 一.Git已经在你的系统中了,你会做一些事情来客户化你的Git环境.你只需要做这些设置一 ...

  7. NET中级课--设计模式1

    1.分类 创建型  结构型  行为型 2.总体思路 使用接口和抽象类 3.创建型 工厂: 单例:整个系统中对象是唯一的或固定数目的对象如对象池 4.结构型

  8. VS 2003 无法打开Web项目 文件路径与URL不符 这两者需要映射到相同的服务器位置

    解决方法: 将C:\Documents   and   Settings\Administrator\VSWebCache下面的文件全部删除

  9. iOS 实现毛玻璃效果

    话说苹果在iOS7.0之后,很多系统界面都使用了毛玻璃效果,增加了界面的美观性,比如下图的通知中心界面; 但是其iOS7.0的SDK并没有提供给开发者实现毛玻璃效果的API,所以很多人都是通过一些别人 ...

  10. struts2 注解方式

    struts2扫描方法: 扫描其位于包的命名注解的类 “struts, struts2, action 或 actions“. 接着,扫描相匹配下列任一条件的文件: 实例了 com.opensymph ...