基于xmpp openfire smack开发之smack类库介绍和使用[2]
http://blog.csdn.net/shimiso/article/details/8816540
关于Smack编程库,前面我们提到,它是面向Java端的api,主要在PC上使用,利用它我们可以向openfire服务器注册用户,发送消息,并且可以通过监听器获得此用户的应答消息,以及构建聊天室,分组,个人通讯录等等。
下面我们写几个程序小例子测试一下。
(1)登录操作
- PPConnection.DEBUG_ENABLED = true;
- AccountManager accountManager;
- final ConnectionConfiguration connectionConfig = new ConnectionConfiguration(
- "192.168.1.78", Integer.parseInt("5222"), "csdn.shimiso.com");
- // 允许自动连接
- connectionConfig.setReconnectionAllowed(true);
- connectionConfig.setSendPresence(true);
- Connection connection = new XMPPConnection(connectionConfig);
- try {
- connection.connect();// 开启连接
- accountManager = connection.getAccountManager();// 获取账户管理类
- } catch (XMPPException e) {
- throw new IllegalStateException(e);
- }
- // 登录
- connection.login("admin", "admin","SmackTest");
- System.out.println(connection.getUser());
- connection.getChatManager().createChat("shimiso@csdn.shimiso.com",null).sendMessage("Hello word!");
运行结果:
在login中一共有三个参数,登录名,密码,资源名,可能有人不明白资源名到底是什么意思,其实就是客户端的来源,客户端的名称,如果不写它默认就叫smack,如果你用相同的账户不同的资源名和同一个人发三条消息,那将会弹出三个窗口,而不是一个窗口。
同时smack还为我们提供了非常好的调试工具Smack Debug,利用该工具我们可以准确的捕获详细的往返报文信息。
(2)下面我们继续写个聊天的例子:
- PPConnection.DEBUG_ENABLED = true;
- AccountManager accountManager;
- final ConnectionConfiguration connectionConfig = new ConnectionConfiguration(
- "192.168.1.78", Integer.parseInt("5222"), "csdn.shimiso.com");
- // 允许自动连接
- connectionConfig.setReconnectionAllowed(true);
- connectionConfig.setSendPresence(true);
- Connection connection = new XMPPConnection(connectionConfig);
- try {
- connection.connect();// 开启连接
- accountManager = connection.getAccountManager();// 获取账户管理类
- } catch (XMPPException e) {
- throw new IllegalStateException(e);
- }
- // 登录
- connection.login("admin", "admin","SmackTest3");
- ChatManager chatmanager = connection.getChatManager();
- Chat newChat = chatmanager.createChat("shimiso@csdn.shimiso.com", new MessageListener() {
- public void processMessage(Chat chat, Message message) {
- if (message.getBody() != null) {
- System.out.println("Received from 【"
- + message.getFrom() + "】 message: "
- + message.getBody());
- }
- }
- });
- Scanner input = new Scanner(System.in);
- while (true) {
- String message = input.nextLine();
- newChat.sendMessage(message);
- }
运行结果:
这里我们用Scanner来捕捉用户在控制台的键盘操作,将信息发出,同时创建了一个MessageListener监听,在其中强制实现processMessage方法即可捕获发回的信息,在初次使用上还是较为容易上手的,我们只要细心查看API即可逐步深入下去。
(3)除了聊天以外我们经常还能想到就是广播
需要给所有在线的用户发送一个通知,或者给所有在线和离线的用户全发送,我们先演示如何给在线用户发送一个广播:
- PPConnection.DEBUG_ENABLED = false;
- AccountManager accountManager;
- final ConnectionConfiguration connectionConfig = new ConnectionConfiguration(
- "192.168.1.78", Integer.parseInt("5222"), "csdn.shimiso.com");
- // 允许自动连接
- connectionConfig.setReconnectionAllowed(true);
- connectionConfig.setSendPresence(true);
- Connection connection = new XMPPConnection(connectionConfig);
- try {
- connection.connect();// 开启连接
- accountManager = connection.getAccountManager();// 获取账户管理类
- } catch (XMPPException e) {
- throw new IllegalStateException(e);
- }
- connection.login("admin", "admin","SmackTest3");
- Message newmsg = new Message();
- newmsg.setTo("shimiso@csdn.shimiso.com");
- newmsg.setSubject("重要通知");
- newmsg.setBody("今天下午2点60分有会!");
- newmsg.setType(Message.Type.headline);// normal支持离线
- connection.sendPacket(newmsg);
- connection.disconnect();
运行结果:
将参数设置为Message.Type.normal即可支持离线广播,openfire系统会自动判断该用户是否在线,如果在线就直接发送出去,如果不在线则将信息存入ofoffline表,现在我将shimiso用户退出登录,再给它发消息,我们可以进入openfire库的ofoffline表中,非常清楚看到里面躺着一条离线消息记录是发给shimiso这个用户的
(4)那么我们如何让shimiso这个用户一登陆就取到离线消息呢?
请看如下代码
- PPConnection.DEBUG_ENABLED = false;
- AccountManager accountManager;
- final ConnectionConfiguration connectionConfig = new ConnectionConfiguration(
- "192.168.1.78", Integer.parseInt("5222"), "csdn.shimiso.com");
- // 允许自动连接
- connectionConfig.setReconnectionAllowed(true);
- connectionConfig.setSendPresence(false);//不要告诉服务器自己的状态
- Connection connection = new XMPPConnection(connectionConfig);
- try {
- connection.connect();// 开启连接
- accountManager = connection.getAccountManager();// 获取账户管理类
- } catch (XMPPException e) {
- throw new IllegalStateException(e);
- }
- connection.login("shimiso", "123","SmackTest");
- OfflineMessageManager offlineManager = new OfflineMessageManager(
- connection);
- try {
- Iterator<org.jivesoftware.smack.packet.Message> it = offlineManager
- .getMessages();
- System.out.println(offlineManager.supportsFlexibleRetrieval());
- System.out.println("离线消息数量: " + offlineManager.getMessageCount());
- Map<String, ArrayList<Message>> offlineMsgs = new HashMap<String, ArrayList<Message>>();
- while (it.hasNext()) {
- org.jivesoftware.smack.packet.Message message = it.next();
- System.out
- .println("收到离线消息, Received from 【" + message.getFrom()
- + "】 message: " + message.getBody());
- String fromUser = message.getFrom().split("/")[0];
- if (offlineMsgs.containsKey(fromUser)) {
- offlineMsgs.get(fromUser).add(message);
- } else {
- ArrayList<Message> temp = new ArrayList<Message>();
- temp.add(message);
- offlineMsgs.put(fromUser, temp);
- }
- }
- // 在这里进行处理离线消息集合......
- Set<String> keys = offlineMsgs.keySet();
- Iterator<String> offIt = keys.iterator();
- while (offIt.hasNext()) {
- String key = offIt.next();
- ArrayList<Message> ms = offlineMsgs.get(key);
- for (int i = 0; i < ms.size(); i++) {
- System.out.println("-->" + ms.get(i));
- }
- }
- offlineManager.deleteMessages();
- } catch (Exception e) {
- e.printStackTrace();
- }
- offlineManager.deleteMessages();//删除所有离线消息
- Presence presence = new Presence(Presence.Type.available);
- nnection.sendPacket(presence);//上线了
- nnection.disconnect();//关闭连接
运行结果:
这里我们需要特别当心的是先不要告诉openfire服务器你上线了,否则永远也拿不到离线消息,用下面英文大概意思就是在你上线之前去获取离线消息,这么设计是很有道理的。
The OfflineMessageManager helps manage offline messages even before the user has sent an available presence. When a user asks for his offline messages before sending an available presence then the server will not send a flood with all the offline messages when the user becomes online. The server will not send a flood with all the offline messages to the session that made the offline messages request or to any other session used by the user that becomes online.
拿到离线消息处理完毕之后删除离线消息offlineManager.deleteMessages() 接着通知服务器上线了。
(5)下面我们来看看如何来发送文件
- PPConnection.DEBUG_ENABLED = false;
- AccountManager accountManager;
- final ConnectionConfiguration connectionConfig = new ConnectionConfiguration(
- "192.168.1.78", Integer.parseInt("5222"), "csdn.shimiso.com");
- // 允许自动连接
- connectionConfig.setReconnectionAllowed(true);
- connectionConfig.setSendPresence(true);
- Connection connection = new XMPPConnection(connectionConfig);
- try {
- connection.connect();// 开启连接
- accountManager = connection.getAccountManager();// 获取账户管理类
- } catch (XMPPException e) {
- throw new IllegalStateException(e);
- }
- connection.login("admin", "admin","Rooyee");
- Presence pre = connection.getRoster().getPresence("shimiso@csdn.shimiso.com");
- System.out.println(pre);
- if (pre.getType() != Presence.Type.unavailable) {
- // 创建文件传输管理器
- FileTransferManager manager = new FileTransferManager(connection);
- // 创建输出的文件传输
- OutgoingFileTransfer transfer = manager
- .createOutgoingFileTransfer(pre.getFrom());
- // 发送文件
- transfer.sendFile(new File("E:\\Chrysanthemum.jpg"), "图片");
- while (!transfer.isDone()) {
- if (transfer.getStatus() == FileTransfer.Status.in_progress) {
- // 可以调用transfer.getProgress();获得传输的进度
- System.out.println(transfer.getStatus());
- System.out.println(transfer.getProgress());
- System.out.println(transfer.isDone());
- }
- }
- }
运行结果:
在这里我们需要特别注意的是,跨资源是无法发送文件的,看connection.login("admin", "admin","Rooyee");这个代码就明白了,必须是“域名和资源名”完全相同的两个用户才可以互发文件,否则永远都没反应,如果不清楚自己所用的客户端的资源名,可以借助前面提到的SmackDebug工具查看往返信息完整报文,在to和from中一定可以看到。
如果我们自己要写文件接收例子的话,参考代码如下:
- FileTransferManager transfer = new FileTransferManager(connection);
- transfer.addFileTransferListener(new RecFileTransferListener());
- public class RecFileTransferListener implements FileTransferListener {
- public String getFileType(String fileFullName) {
- if (fileFullName.contains(".")) {
- return "." + fileFullName.split("//.")[1];
- } else {
- return fileFullName;
- }
- }
- @Override
- public void fileTransferRequest(FileTransferRequest request) {
- System.out.println("接收文件开始.....");
- final IncomingFileTransfer inTransfer = request.accept();
- final String fileName = request.getFileName();
- long length = request.getFileSize();
- final String fromUser = request.getRequestor().split("/")[0];
- System.out.println("文件大小:" + length + " " + request.getRequestor());
- System.out.println("" + request.getMimeType());
- try {
- JFileChooser chooser = new JFileChooser();
- chooser.setCurrentDirectory(new File("."));
- int result = chooser.showOpenDialog(null);
- if (result == JFileChooser.APPROVE_OPTION) {
- final File file = chooser.getSelectedFile();
- System.out.println(file.getAbsolutePath());
- new Thread() {
- public void run() {
- try {
- System.out.println("接受文件: " + fileName);
- inTransfer
- .recieveFile(new File(file
- .getAbsolutePath()
- + getFileType(fileName)));
- Message message = new Message();
- message.setFrom(fromUser);
- message.setProperty("REC_SIGN", "SUCCESS");
- message.setBody("[" + fromUser + "]发送文件: "
- + fileName + "/r/n" + "存储位置: "
- + file.getAbsolutePath()
- + getFileType(fileName));
- if (Client.isChatExist(fromUser)) {
- Client.getChatRoom(fromUser)
- .messageReceiveHandler(message);
- } else {
- ChatFrameThread cft = new ChatFrameThread(
- fromUser, message);
- cft.start();
- }
- } catch (Exception e2) {
- e2.printStackTrace();
- }
- }
- }.start();
- } else {
- System.out.println("拒绝接受文件: " + fileName);
- request.reject();
- Message message = new Message();
- message.setFrom(fromUser);
- message.setBody("拒绝" + fromUser + "发送文件: " + fileName);
- message.setProperty("REC_SIGN", "REJECT");
- if (Client.isChatExist(fromUser)) {
- Client.getChatRoom(fromUser).messageReceiveHandler(message);
- } else {
- ChatFrameThread cft = new ChatFrameThread(fromUser, message);
- cft.start();
- }
- }
- /*
- * InputStream in = inTransfer.recieveFile();
- *
- * String fileName = "r"+inTransfer.getFileName();
- *
- * OutputStream out = new FileOutputStream(new
- * File("d:/receive/"+fileName)); byte[] b = new byte[512];
- * while(in.read(b) != -1) { out.write(b); out.flush(); }
- *
- * in.close(); out.close();
- */
- } catch (Exception e) {
- e.printStackTrace();
- }
- System.out.println("接收文件结束.....");
- }
- }
(6)用户列表
- **
- * 返回所有组信息 <RosterGroup>
- *
- * @return List(RosterGroup)
- */
- public static List<RosterGroup> getGroups(Roster roster) {
- List<RosterGroup> groupsList = new ArrayList<RosterGroup>();
- Collection<RosterGroup> rosterGroup = roster.getGroups();
- Iterator<RosterGroup> i = rosterGroup.iterator();
- while (i.hasNext())
- groupsList.add(i.next());
- return groupsList;
- }
- /**
- * 返回相应(groupName)组里的所有用户<RosterEntry>
- *
- * @return List(RosterEntry)
- */
- public static List<RosterEntry> getEntriesByGroup(Roster roster,
- String groupName) {
- List<RosterEntry> EntriesList = new ArrayList<RosterEntry>();
- RosterGroup rosterGroup = roster.getGroup(groupName);
- Collection<RosterEntry> rosterEntry = rosterGroup.getEntries();
- Iterator<RosterEntry> i = rosterEntry.iterator();
- while (i.hasNext())
- EntriesList.add(i.next());
- return EntriesList;
- }
- /**
- * 返回所有用户信息 <RosterEntry>
- *
- * @return List(RosterEntry)
- */
- public static List<RosterEntry> getAllEntries(Roster roster) {
- List<RosterEntry> EntriesList = new ArrayList<RosterEntry>();
- Collection<RosterEntry> rosterEntry = roster.getEntries();
- Iterator<RosterEntry> i = rosterEntry.iterator();
- while (i.hasNext())
- EntriesList.add(i.next());
- return EntriesList;
- }
(7)用户头像的获取
使用VCard,很强大,具体自己看API吧,可以看看VCard传回来XML的组成,含有很多信息的
- **
- * 获取用户的vcard信息
- * @param connection
- * @param user
- * @return
- * @throws XMPPException
- */
- public static VCard getUserVCard(XMPPConnection connection, String user) throws XMPPException
- {
- VCard vcard = new VCard();
- vcard.load(connection, user);
- return vcard;
- }
- /**
- * 获取用户头像信息
- */
- public static ImageIcon getUserImage(XMPPConnection connection, String user) {
- ImageIcon ic = null;
- try {
- System.out.println("获取用户头像信息: "+user);
- VCard vcard = new VCard();
- vcard.load(connection, user);
- if(vcard == null || vcard.getAvatar() == null)
- {
- return null;
- }
- ByteArrayInputStream bais = new ByteArrayInputStream(
- vcard.getAvatar());
- Image image = ImageIO.read(bais);
- ic = new ImageIcon(image);
- System.out.println("图片大小:"+ic.getIconHeight()+" "+ic.getIconWidth());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ic;
- }
(8)组操作和用户分组操作
- **
- * 添加一个组
- */
- public static boolean addGroup(Roster roster,String groupName)
- {
- try {
- roster.createGroup(groupName);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 删除一个组
- */
- public static boolean removeGroup(Roster roster,String groupName)
- {
- return false;
- }
- /**
- * 添加一个好友 无分组
- */
- public static boolean addUser(Roster roster,String userName,String name)
- {
- try {
- roster.createEntry(userName, name, null);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 添加一个好友到分组
- * @param roster
- * @param userName
- * @param name
- * @return
- */
- public static boolean addUser(Roster roster,String userName,String name,String groupName)
- {
- try {
- roster.createEntry(userName, name,new String[]{ groupName});
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- /**
- * 删除一个好友
- * @param roster
- * @param userName
- * @return
- */
- public static boolean removeUser(Roster roster,String userName)
- {
- try {
- if(userName.contains("@"))
- {
- userName = userName.split("@")[0];
- }
- RosterEntry entry = roster.getEntry(userName);
- System.out.println("删除好友:"+userName);
- System.out.println("User: "+(roster.getEntry(userName) == null));
- roster.removeEntry(entry);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
(9)用户查询
- public static List<UserBean> searchUsers(XMPPConnection connection,String serverDomain,String userName) throws XMPPException
- {
- List<UserBean> results = new ArrayList<UserBean>();
- System.out.println("查询开始..............."+connection.getHost()+connection.getServiceName());
- UserSearchManager usm = new UserSearchManager(connection);
- Form searchForm = usm.getSearchForm(serverDomain);
- Form answerForm = searchForm.createAnswerForm();
- answerForm.setAnswer("Username", true);
- answerForm.setAnswer("search", userName);
- ReportedData data = usm.getSearchResults(answerForm, serverDomain);
- Iterator<Row> it = data.getRows();
- Row row = null;
- UserBean user = null;
- while(it.hasNext())
- {
- user = new UserBean();
- row = it.next();
- user.setUserName(row.getValues("Username").next().toString());
- user.setName(row.getValues("Name").next().toString());
- user.setEmail(row.getValues("Email").next().toString());
- System.out.println(row.getValues("Username").next());
- System.out.println(row.getValues("Name").next());
- System.out.println(row.getValues("Email").next());
- results.add(user);
- //若存在,则有返回,UserName一定非空,其他两个若是有设,一定非空
- }
- return results;
- }
(10)修改自身状态
包括上线,隐身,对某人隐身,对某人上线
- ublic static void updateStateToAvailable(XMPPConnection connection)
- {
- Presence presence = new Presence(Presence.Type.available);
- nnection.sendPacket(presence);
- public static void updateStateToUnAvailable(XMPPConnection connection)
- {
- Presence presence = new Presence(Presence.Type.unavailable);
- nnection.sendPacket(presence);
- }
- public static void updateStateToUnAvailableToSomeone(XMPPConnection connection,String userName)
- {
- Presence presence = new Presence(Presence.Type.unavailable);
- presence.setTo(userName);
- nnection.sendPacket(presence);
- }
- public static void updateStateToAvailableToSomeone(XMPPConnection connection,String userName)
- {
- Presence presence = new Presence(Presence.Type.available);
- presence.setTo(userName);
- nnection.sendPacket(presence);
- }
(11)心情修改
- **
- * 修改心情
- * @param connection
- * @param status
- */
- public static void changeStateMessage(XMPPConnection connection,String status)
- {
- Presence presence = new Presence(Presence.Type.available);
- presence.setStatus(status);
- connection.sendPacket(presence);
- }
(12)修改用户头像
有点麻烦,主要是读入图片文件,编码,传输之
- public static void changeImage(XMPPConnection connection,File f) throws XMPPException, IOException{
- VCard vcard = new VCard();
- vcard.load(connection);
- byte[] bytes;
- bytes = getFileBytes(f);
- String encodedImage = StringUtils.encodeBase64(bytes);
- vcard.setAvatar(bytes, encodedImage);
- vcard.setEncodedImage(encodedImage);
- vcard.setField("PHOTO", "<TYPE>image/jpg</TYPE><BINVAL>"
- + encodedImage + "</BINVAL>", true);
- ByteArrayInputStream bais = new ByteArrayInputStream(
- vcard.getAvatar());
- Image image = ImageIO.read(bais);
- ImageIcon ic = new ImageIcon(image);
- vcard.save(connection);
- }
- private static byte[] getFileBytes(File file) throws IOException {
- BufferedInputStream bis = null;
- try {
- bis = new BufferedInputStream(new FileInputStream(file));
- int bytes = (int) file.length();
- byte[] buffer = new byte[bytes];
- int readBytes = bis.read(buffer);
- if (readBytes != buffer.length) {
- throw new IOException("Entire file not read");
- }
- return buffer;
- } finally {
- if (bis != null) {
- bis.close();
- }
- }
- }
(13)用户状态的监听
即对方改变头像,状态,心情时,更新自己用户列表,其实这里已经有smack实现的监听器
- nal Roster roster = Client.getRoster();
- roster.addRosterListener(
- new RosterListener() {
- @Override
- public void entriesAdded(Collection<String> arg0) {
- // TODO Auto-generated method stub
- System.out.println("--------EE:"+"entriesAdded");
- }
- @Override
- public void entriesDeleted(Collection<String> arg0) {
- // TODO Auto-generated method stub
- System.out.println("--------EE:"+"entriesDeleted");
- }
- @Override
- public void entriesUpdated(Collection<String> arg0) {
- // TODO Auto-generated method stub
- System.out.println("--------EE:"+"entriesUpdated");
- }
- @Override
- public void presenceChanged(Presence arg0) {
- // TODO Auto-generated method stub
- System.out.println("--------EE:"+"presenceChanged");
- }
- });
基于xmpp openfire smack开发之smack类库介绍和使用[2]的更多相关文章
- 基于xmpp openfire smack开发之Android客户端开发[3]
在上两篇文章中,我们依次介绍openfire部署以及smack常用API的使用,这一节中我们着力介绍如何基于asmack开发一个Android的客户端,本篇的重点在实践,讲解和原理环节,大家可以参考前 ...
- iOS-iPad开发之SplitViewController简单介绍
iOS-iPad开发之SplitViewController简单介绍 SplitViewController图形化创建 SplitViewController可以并列显示两个view,适用于基于nav ...
- iOS-iPad开发之popoverController使用介绍
iOS-iPad开发之popoverController使用介绍 iOS开发UI篇-popoverController使用注意 iOS SDK:自定义Popover(弹出窗口) 实现的简单例子: // ...
- 基于xmpp openfire smack开发之openfire介绍和部署[1]
前言 http://blog.csdn.net/shimiso/article/details/8816558 Java领域的即时通信的解决方案可以考虑openfire+spark+smack.当然也 ...
- Linux内核驱动开发之KGDB原理介绍及kgdboe方式配置
接博文<Linux内核驱动开发之KGDB单步调试内核(kgdboc方式)>.上篇博文中,仅简单介绍使用串口的Kgbd的流程(kgdboc方式),本文将重点介绍KGDB调试Linux内核的原 ...
- Pilin —— 一个基于Xmpp openfire smack的即时聊天工具
https://github.com/whfcomm/Pilin
- 8天掌握EF的Code First开发之Entity Framework介绍
返回<8天掌握EF的Code First开发>总目录 本篇目录 Entity Framework概要 什么是ORM Entity Framework简史 Entity Framework具 ...
- 转载 8天掌握EF的Code First开发之Entity Framework介绍
转载原地址: http://www.cnblogs.com/farb/p/IntroductionToEF.html Entity Framework概要 Entity Framework是微软的O ...
- 测试开发之Django——No1.介绍以及引申
前言 > 测试行业发展飞速,自动化测试兴起,由此对测试人员的要求与日俱增.随时而来的,就是职能的增加. > 首先需要学习的,就是自动化测试.而由自动化测试引申而来的,就是另外几个新增的岗位 ...
随机推荐
- sae的kvdb使用注意
之前没仔细看,原来sae的kvdb使用一定要先调用初始化函数 $kv = new SaeKV(); $kv->init();//必须使用 $kv->set('index', $data);
- JS+CSS实现选项卡功能
[小小一记] 首先我们写一个选项卡的结构出来,包括tab和content: 首先是tab: <ul class="ttitle-box-tabs" id="tabs ...
- Java控制台版推箱子
import java.util.Scanner; public class b { public static void main(String[] args) { Scanner input = ...
- DataTable 无法转换的错误
目前基本上检索都已经离不开Linq了.所以最近在Linq的过程中出现了一些意外情况,特此记录下来. 先描述一下场景: 有一个查询的要求是这样的,检索出Status > 1 的数据.因为要根据其他 ...
- vs2015安装没有wim32
刚开始在官网上下载VS2015没在意太多,选择了默认安装,结果是没有win64的,所以就不能写c代码.默认安装很多库都没有,所以要什么都得下载.转载一篇文章
- Entity Framework 实践系列 —— 搞好关系 - 单相思(单向一对一,one-to-one)【转】
原以为躲入代码世界,就可以不用搞关系,哪知“关系无处不在”.写代码多年之后,终于明白“面向对象的关键是搞好对象之间的关系”.而Entity Framework作为ORM中的明日之星,首当其冲的使命就是 ...
- Action类一般情况为何要继承ActionSupport
struts2中的action可以继承ActionSupport,也可以不继承ActionSupport.不继承ActionSupport的情况只需要有一个方法,返回String,即可,记住,在继承A ...
- spoj 4487. Can you answer these queries VI (gss6) splay 常数优化
4487. Can you answer these queries VI Problem code: GSS6 Given a sequence A of N (N <= 100000) in ...
- SQL servere 范式、事务
一.数据库范式: 1.构造数据库必须遵循一定的规则.在关系数据库中,这种规则就是范式. 范式是符合某一种级别的关系模式的集合.数据库中的关系必须满足一定的要求,即满足不同的范式. 满足最低要求的范式是 ...
- sqlite3使用入门
sqlite的安装 1. 首先是下载sqlite,可以该页面下载:http://www.sqlite.org/download.html 当前的最新版本为:sqlite-shell-win32-x86 ...