java if else 判断boolean类型不管true还是false执行只执行if 5C

mAdapter.setOnTreeNodeClickListener(new TreeListViewAdapter.OnTreeNodeClickListener()
{
@Override
public void onClick(Node node, int position) {

                        if (node.isLeaf()) { //这里node.isleaf()为false 为什么还执行进去而且else都不执行
                            LogUtil.LogPrint("login", "第一次if0" + node.isleaf());
                            sonAttrabuite = node.getAttributespath();
                            LogUtil.LogPrint("login", "" + node.isleaf());
                            handler.sendEmptyMessage(HandlerOrder.Three_son);
                        } else {
                            LogUtil.LogPrint("login", "第一次else0" + node.isleaf());
                            if (MainActivity.ifPage == 1) {
                                MainActivity.attributespath = node.getAttributespath();
                                MainActivity.attributespath_Warni = (String) SPUtils.get(ctx, "attributesPath", "");
                                MainActivity.atrributepathName = node.getName();
                            } else if (MainActivity.ifPage == 2) {
                                MainActivity.attributespath_Car = node.getAttributespath();
                                MainActivity.attributespath_Warni = (String) SPUtils.get(ctx, "attributesPath", "");
                                MainActivity.atrributepathName_Car = node.getName();
                            } else if (MainActivity.ifPage == 3) {
                                MainActivity.attributespath_Warni = node.getAttributespath();
                                MainActivity.atrributepathName_Warni = node.getName();
                            }

                            TreeActivity.this.finish();
                        }


                        }  });
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

11个回答

楼主,我觉得这种可能性不高,可能是你的编译文件不对,程序执行的和你最新的代码不一样,建议重新编译一下

java if else 判断boolean类型不管true还是false执行只执行if

这种问题是违反 if 结构的

应该是你判断条件错误
或根本就没有判断

if (node.isLeaf()) { //这里node.isleaf()为false 为什么还执行进去而且else都不执行
你判断一下是不是真的为node.isleaf() == false ,
这意思是node.isleaf() 个值是永真的,改变并没有对其产生影响

你应该重点发展这里

不然你可以试试,直接把 node.isleaf() 换成 true ,在换成 false 肯定执行结果不同

if (true)

if (false)

首先建议你在后台输出一下node.isLeaf() 的值,看是否为true或false;可能是代码的结构哪里出了问题,导致这里方法返回的结果出问题。

建议你把这个方法的代码也贴一下出来,便于分析。

楼主,你这if else外面还有两层域,确定是否进到if else这一层了,如果进到if else这一层,就看日志,确定是进if还是进else,如果node.isleaf()为false还进到if里面,说明编译有问题重新编译部署测试。跟踪日志就行。if else没有问题的

node.isLeaf()这个是获取的一个值而已,我每次都打印出来了,不管node.isleaf()=true或者node.isleaf()=false都只执行if的方法。真的头痛,各位请指教啊。

现在不管是true还是false都只执行else方法了,真的这个逻辑都没错啊,为什么会这样。

劝你进入main方法测试这node.isLeaf()是否有值 ,返回值是否布尔值
用debug模式跟一下,或者直接打印你想看的值

不存在这种神秘事件,还是好好debug看看

删除class文件,重新编译

建议重新编译..eclipse建议clean下....有可能是缓存

共11条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
JAVA关于if再嵌套if以及判断Boolean逻辑的问题~~~
package taxi; import java.util.*; public class taxi { public taxi() { } public static void main(String[] args) { Scanner ms=new Scanner(System.in); System.out.println("输入里程"); double km=ms.nextDouble(); System.out.println("请输入等待时间,小于5min不计"); int wt=ms.nextInt(); int wp=wt/5*2; double pay=0; System.out.println("输入day or night"); boolean time=ms.nextBoolean(); boolean day=true; if(day==true) { if(km<=3) { pay=12+wp; System.out.println(pay); } else if(km<=10) { pay=12+(km-3)*2.4+wp; System.out.println(pay); } else if(km>10) { pay=12+7*2.4+(km-10)*3.6+wp; } else { if(km<=3) { pay=16+wp; } else if(km<=10) { pay=16+(km-3)*3.1+wp; } else { pay=16+7*3.1+(km-10)*4.6+wp; } } } System.out.println("*****************消费清单****************"); System.out.println("里程"+"\t"+km+"KM"+"\n"+"等待时间"+"\t"+wt+"MIN"+"\n"+"总计"+"\t"+pay+"¥"+"\n"); } } 我们老师布置的课程项目就是做一个关于出租车计费的问题,但是要分白天和黑夜两种计费方式,那么问题来了,老师在课上大概的说了一下,就是用boolean去定义day为true,night为false,当day= =true的时候执行白天的收费标准,否则执行晚上的收费标准!我就卡在了,if判断逻辑那里,代码如上,执行后就是exception之类的,实在不懂! 我是小白,这道题老师没有细讲,流程图我会画,但是没办法用程序语言表达出来!
java对象属性的默认值影响sql查询语句的拼接,该如何处理。
1、问题描述: 想做一个通用的sql查询语句,通过传入对象的属性赋值情况,拼接查询语句。比如Admin类,有int id,String name,int age,boolean isLeader 4个属性,如果给Admin的对象的某几个属性赋值,比如:setAge(32);setName(“张”)。那么语句拼接为select * from admin where age=32 and name like '%张%'。我在拼接时本来想通过属性是否为null,或者是否为空字符来判断是否作为查询条件,但是由于默认值的存在,导致拼接错误。 2、代码 ``` /*** * 约定: * 1、类名与表名对应,表名全小写。 * 2、类属性与列名一致。 * 3、ID列的类属性和列名为=表名(第一个字母小写)+“Id” * * 4、暂不支持联表查询。 *类名:BaseDao * ***/ public <T> List<T> query(T t) throws IllegalArgumentException, IllegalAccessException, SQLException{ StringBuilder sql=new StringBuilder(); StringBuilder whereString=new StringBuilder(); List<Object> parameters=new ArrayList<Object>(); Class clazz=t.getClass(); //获取类名 String classSimpleName=clazz.getSimpleName(); //获取表名 String tableName=classSimpleName.toLowerCase(); //拼接select语句前半部分 sql.append("select * from "+tableName); //获取所有类属性 Field[] fields=clazz.getDeclaredFields(); //遍历所有属性 for(Field field:fields) { field.setAccessible(true); //得到属性值 Object fieldValue=field.get(t); if(fieldValue!=null) { //如果属性值不为null,获取属性名(字段名)。 String fieldName=field.getName(); //判断是否为String类型 if(fieldValue instanceof String) { // 如果是String,判断是否为空字符 if(!("".equals(((String)fieldValue).trim()))) { //不是空字符串,作为where条件,并将参数加入列表。 whereString.append(fieldName+" like ? and "); parameters.add("%"+(String)fieldValue+"%"); } }else if("Integer".equals(fieldValue.getClass().getSimpleName())){ /***判断是否为int,如果int>0,认为参数有效---这个也是为了处理默认值为0的情况,想的办法,但是有时候表里面字段值可能<=0,所以我觉得处理得不**好*/ if((int)fieldValue>0) { whereString.append(fieldName+"=? and "); parameters.add(fieldValue); } }else{ /*其他情况直接作为where查询条件,但是运行发现boolean值默认false,也会直接当成是有效条件,影响条件设置*/ whereString.append(fieldName+"=? and "); parameters.add(fieldValue); } } } //判断是否有有效条件,有的话拼接where语句。 if(parameters.size()>0) { whereString.delete(whereString.length()-5, whereString.length()-1); sql.append(" where "); sql.append(whereString); } System.out.println(sql.toString()); System.out.println(parameters); //连接数据库,查询。 QueryRunner qr=JdbcPool.getQueryRunner(); // return null; return qr.query(sql.toString(), new BeanListHandler<T>(clazz), parameters.toArray()); } ``` 3、测试代码 ``` @Test public void BaseDao() throws Exception, IllegalAccessException { IpAddress ipObj=new IpAddress(); //只设置了一个条件。 ipObj.setIpAddress("192.168.1"); BaseDao bd=new BaseDao(); List<IpAddress> list=bd.query(ipObj); for(IpAddress ip:list) { System.out.println(ip); } System.out.println(list.size()); } ``` 4、结果 ``` //在只设置了一个条件的情况下,拼接出两个查询条件。 select * from ipaddress where ipAddress like ? and isReachable=? [%192.168.1%, false] ``` 5、问题: 请问如何处理这种由于对象基本类型默认值,导致的拼接错误的问题?
java里如果用boolean计算多个数值?
比如我想用Boolean来计算哪一些年是闰年 哪些不是 我是java新手 我是这么写的 int year=1999; for(int nyear=year-10;nyear<=year+10;year++) 怎么样才能用boolean来计算上面的所有nyear数值为 true 或者是 false 我试过用 if else语句 但是if else计算出来的Boolean是不能被赋值的 我无法使用它 求大神解答一下我的困惑 是哪里出问题了
Java编程思想 哲学家问题 为什么为哲学家增加思考的时间,就能缓解死锁的产生?
我十分不解,为什么在Philosopher类中的run()内增加pause()就能让死锁慢一点发生?请大神指教 这个例子中,产生死锁的原因在于,所有的哲学家都拿到了右筷子,却因为拿不到左筷子而陷入循环等待。但这和是否使用pause()有关系吗?可以注意到例子中使用的随机数赋予了种子,也就是说,每次运行得到的结果是一个固定且相同的值,即便是加了pause(),等待哪怕1000秒,当1000秒后,所有的哲学家仍然同时由等待状态转变成了可运行态,接着受到线程调度器分配时间片来驱动,这和等待时间的长短又有什么必然的关系呢???(ps: 我的理解是把种子去掉,不同的哲学家思考的时间不同,进入"拿筷子"阶段的时间不同,**降低同时请求共享资源的可能性**,这样倒是能缓解死锁发生的概率,书上的说法实在是无法理解) 请先避开不谈满足死锁的四个条件。直接讨论这个例子。 ``` /** * 哲学家问题 筷子 */ public class Chopstick { private boolean taken = false; public synchronized void take(int id, String direction) throws InterruptedException{ while(taken) { System.out.println("Philosopher " + id + " waiting " + direction + " chopstick"); this.wait(); } // 现在由新的哲学家持有这根筷子 taken = true; System.out.println("Philosopher " + id + " grabbed " + direction + " chopstick"); } public synchronized void drop() { taken = false; this.notifyAll(); } } ``` ``` /** * 哲学家问题 哲学家 */ public class Philosopher implements Runnable{ private Chopstick left; private Chopstick right; private final int id; private final int ponderFactor; private Random rand = new Random(47); private void pause() throws InterruptedException{ if(ponderFactor == 0) { return; } TimeUnit.MILLISECONDS.sleep(rand.nextInt(ponderFactor * 250)); } public Philosopher(Chopstick left, Chopstick right, int ident, int ponder) { this.left = left; this.right = right; this.id = ident; this.ponderFactor = ponder; } @Override public void run() { try { while(!Thread.interrupted()) { // 为什么加上的等待时间越长,产生死锁的可能性越小? pause(); //System.out.println(this + " beginning eating " + LocalDateTime.now().getNano()); // 哲学家开始变饿 System.out.println(this + " " + "grabbing right"); right.take(id, "right"); System.out.println(this + " " + "grabbing left"); left.take(id, "left"); System.out.println(this + " " + "eating"); pause(); right.drop(); left.drop(); } }catch (InterruptedException e) { System.out.println(this + " " + "exiting via interrupt"); } } public String toString() { return "Philosopher " + id; } } ``` ``` /** * 哲学家问题 演示死锁 */ public class DeadlockingDiningPhilosopher { public static void main(String[] args) throws InterruptedException, IOException { int ponder = 5; if(args.length > 0) { ponder = Integer.parseInt(args[0]); } int size = 5; if (args.length > 1) { size = Integer.parseInt(args[1]); } ExecutorService exec = Executors.newCachedThreadPool(); Chopstick[] sticks = new Chopstick[size]; for(int i = 0; i < size; i++) { sticks[i] = new Chopstick(); } for (int i = 0; i < size; i++) { exec.execute(new Philosopher(sticks[i], sticks[(i+1) % size], i, ponder)); } if (args.length == 3 && args[2].equals("timeout")) { TimeUnit.SECONDS.sleep(5); } else { System.out.println("Press 'Enter' to quit"); System.in.read(); } exec.shutdownNow(); } } ```
实现操作系统页面置换算法,调用的ListUtils.java中的代码都是什么意思?能否帮忙解释一下原理?
我在用Java做操作系统中的页面置换算法,实现FIFO,CLOCK和LRU这三种算法,在这三个算法实现的过程中,都调用了ListUtils.java,但是我不懂ListUtils.java中的代码是什么意思,导致我其他的代码也看不懂。向各位大神请教一下,能否解释一下ListUtils.java中代码的含义和原理?感谢感谢! 另外在算法中的 Object[] strList = list.toArray(); for(int column = 0; column < list.size(); column++) { FIFOData[column][i+1] = strList[column]; } 这两行代码是什么意思呢?我看在每一个页面置换算法中都有这两行代码,但是我看不懂!麻烦各位大佬帮忙看一下!万分感谢! 下面贴上代码: ListUtils.java ``` package utils; import java.util.List; public class ListUtils { public ListUtils() { } /** * 输出 * @param list 将List转为数组并输出, out: 2, 3, 4 * @return */ public static String listToString(List list){ StringBuffer content = new StringBuffer(); for(int i = 0; i < list.size(); i++){ content.append(list.get(i)); if(i < list.size() - 1){ content.append(","); } } return content.toString(); } /** * 在list中查找是否有str * @param list * @param str * @return */ public static boolean find(List<String> list, String str){ boolean flag = false; for(String lis : list){ if(lis.equals(str)){ flag = true; } } return flag; } /** * 在List中查找是否有String,如果有返回下标, 否则返回 -1 * @param list * @param str * @return */ public static int findIndex(List<String> list, String str) { int index = 0; for(String lis : list) { if(lis.equals(str)) { return index; } index++; } return -1; } public static boolean clockJudge(String[] clock, int index) { if(clock[index].equals("0")) { return true; } return false; } /** * * @param index 下标 * @param clock 时钟 * @param range 当前使用内存块 * @return */ public static int findZero(int index, String[] clock, int range) { while(true) { if(clock[index].equals("0")) { break; }else { clock[index] = "0"; index++; if(index > range-1) { index = Math.abs(range - index); } } } return index; } /** * 在数组中查找是否存在该字符串 * @param obj * @param str * @return */ public static boolean strJudge(Object[] obj, String str) { boolean flag = false; if(obj == null) { return flag; } for(int i = 0; i < obj.length; i++) { if(str.equals(obj[i])) { flag = true; break; } } return flag; } /** * 获取二维数组中同一列的行的长度 * @param str 数据 * @param length 二维数组的列 * @param memory 内存块 * @return * */ public static int findNull(Object[][] str, int length, int memory) { int index = 0; if(str == null) { return -1; } for(int i = 0; i < memory; i++) { if(str[i][length] != null) { index = i; } } return index; } } ``` 在FIFO中调用: ![图片说明](https://img-ask.csdn.net/upload/201912/16/1576503707_674210.png) 在URL中调用: ![图片说明](https://img-ask.csdn.net/upload/201912/16/1576503832_866034.png) 在Clock中调用: ![图片说明](https://img-ask.csdn.net/upload/201912/16/1576503948_604271.png)
数据结构JAVA equals方法的调用
``` public boolean equals(BinaryNode<T> parent,BinaryNode<T> pattern) { if(parent==null&&pattern==null) return true; if(parent==null||pattern==null) return false; if(parent.getdata().equals(pattern.getdata())) return equals(parent.left,pattern.left)&&equals(parent.right,pattern.right); return false; }//比较两节点是否相等 ``` ``` //BinaryNode<T> search(BinaryTree<T> pattern) //先根次序遍历查找首个与pattern匹配的子树 public BinaryNode<T> search(BinaryTree<T> pattern) { return search(pattern.root,this.root); } private BinaryNode<T> search(BinaryNode<T> pattern,BinaryNode<T> parent) { if(parent==null) return null; ****if(parent.equals(pattern)) //这边调用equals的时候,老师说不是这样写的,那我应该怎么写啊 return parent;**** else { BinaryNode<T> l = search(pattern,parent.left); if(l!=null) return l; BinaryNode<T> r =search(pattern,parent.right); if(r!=null) return r; } return null; } ```
请问这段代码为什么不给我输出呢?
链表 public class ListNode{ public int data; public ListNode next; public ListNode(int data) { this.data=data; } public class List { ListNode head; public List() { head=null; } public void add(int data) { ListNode node=new ListNode(data); ListNode current; if (head==null) { head=node; } else { current=head; while(current.next!=null) { current=current.next; } current.next=node; } } public boolean insert(int data,int insertPosition) { ListNode node=new ListNode(data); ListNode current=head;; if (head==null) { return false; } else { for(int i=0;i<insertPosition-1;i++) { if(current.next==null) { return false; } current=current.next; } node.next=current.next; current.next=node; return true; } } public String toString() { ListNode current=head; String result=""; while(current.next!=null) { result+=current.data+"\n"; } return result; } public static void main(String[] args) { List numberList=new List(); numberList.add(3); numberList.add(9); numberList.add(8); numberList.add(5); numberList.add(2); numberList.add(6); System.out.println(numberList); } }
java web的Filter和cookie退出登陆问题求解!
我要做一个退出登陆的功能,因为是两个不同的页面(index和index1),但是用户表用的是同一个,即账号密码名称一样,现在从退出index页面能顺利推到login页面,但是从index1退出会先进入index页面后再次点击退出才退出到login,怎样才可以也让index1直接推到login? 下面是相关代码: ``` //LoginFilter部分 HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; String path = req.getContextPath(); String basepath = req.getScheme()+"://"+req.getServerName()+":"+req.getServerPort()+path+"/"; String uri = req.getRequestURI(); if(uri.contains("/LoginServlet")||uri.contains("/RegisterServlet")||uri.contains("/css/")||uri.contains("/iconfont/")||uri.contains("/image/")||uri.contains("/js/")||uri.contains("/layui/")||uri.contains("/CheckCodeServlet")){ chain.doFilter(request, response); }else if(uri.contains("/login.jsp")){ Object user = req.getSession().getAttribute("user"); if(user!=null){ System.out.println("3"); res.sendRedirect(basepath+"jsp\\index.jsp"); //res.sendRedirect(basepath+"jsp\\index1.jsp"); }else{ chain.doFilter(request, response); } }else if(uri.contains("/register.jsp")){ Object user = req.getSession().getAttribute("user"); if(user!=null){ res.sendRedirect(basepath+"jsp\\index.jsp"); }else{ chain.doFilter(request, response); } } else{ Object user = req.getSession().getAttribute("user"); if(user!=null){ chain.doFilter(request, response); }else{ res.sendRedirect(basepath+"login.jsp"); } } //CookieLoginFilter部分 HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; Cookie[] cookies = req.getCookies(); boolean flag = false; boolean flag1 = false; if(cookies!=null){ for(Cookie cookie:cookies){ if("username".equals(cookie.getName())){ flag=true; break; } } } if(flag){ res.sendRedirect("LoginServlet"); }else if(flag1) { res.sendRedirect("RegisterServlet"); }else{ chain.doFilter(request, response); } //LogoutServlet部分 HttpSession session = request.getSession(); /*session.removeAttribute("name");*/ session.invalidate(); Cookie cookieName = new Cookie("username",null); cookieName.setMaxAge(0); cookieName.setPath("/"); Cookie cookiePwd = new Cookie("password",null); cookiePwd.setMaxAge(0); cookiePwd.setPath("/"); Cookie cookieUpower = new Cookie("upower",null); cookieUpower.setMaxAge(0); cookieUpower.setPath("/"); response.addCookie(cookieName); response.addCookie(cookiePwd); response.addCookie(cookieUpower); response.sendRedirect("login.jsp"); //loginoutservlet部分 HttpSession session = request.getSession(); //session.removeAttribute("name"); session.invalidate(); Cookie cookieName = new Cookie("username",null); cookieName.setMaxAge(0); cookieName.setPath("/"); Cookie cookiePwd = new Cookie("password",null); cookiePwd.setMaxAge(0); cookiePwd.setPath("/"); Cookie cookieUpower = new Cookie("upower",null); cookieUpower.setMaxAge(0); cookieUpower.setPath("/"); response.addCookie(cookieName); response.addCookie(cookiePwd); response.addCookie(cookieUpower); response.sendRedirect("login.jsp"); //index1的jsp部分 <header class="layout-header"> <span class="header-logo">图书馆系统</span> <div class="dl-log">欢迎您,<span class="dl-log-user">${user.username}</span><a href="../login.jsp" title="退出系统" class="dl-log-quit">[退出]</a> <a class="header-menu-btn" href="javascript:;"><i class="icon-font">&#xe600;</i></a> </div> </header> ```
java贪吃蛇怎样设置向左时不能向右
package moonsake; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.Random; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.Timer; public class MPanel extends JPanel implements KeyListener/*实现接口KeyListener开始监听键盘输入*/ ,ActionListener{ private ImageIcon title = new ImageIcon("title.jpg"); private ImageIcon right = new ImageIcon("right.png"); private ImageIcon body = new ImageIcon("body.png"); private ImageIcon down = new ImageIcon("down.png"); private ImageIcon left = new ImageIcon("left.png"); private ImageIcon up = new ImageIcon("up.png"); private ImageIcon food = new ImageIcon("food.png"); int len = 3;//长度 int score = 0;//分数 private static int speed =150; int[] snakex = new int[750]; int[] snakey = new int[750]; String fx = "R"; //反向R, L, U, D boolean isStared = false;//暂停字体 boolean isEnd = false;//结束 boolean flag = false; Timer timer = new Timer( speed,this); int foodx; int foody; Random rand = new Random(); public MPanel(){ initsnake(); //设置焦点为自己 this.setFocusable(true); //设置自己为键盘监听对象 this.addKeyListener(this); timer.start(); foodx = 25 + 25*rand.nextInt(34); foody = 75 + 25*rand.nextInt(24); } public void initsnake() { len = 3; snakex[0] = 100; snakey[0] = 100; snakex[1] = 75; snakey[1] = 100; snakex[2] = 50; snakey[2] = 100; fx = "R"; score = 0; } public void paintComponent(Graphics g) { super.paintComponent(g); this.setBackground(Color.WHITE); title.paintIcon(this, g, 25, 11); g.fillRect(25,75 , 850, 600); g.drawString("长度:"+len, 750, 35); g.drawString("分数:"+score, 750, 50); //暂停语句 if(isStared == false) { g.setColor(Color.WHITE); g.setFont(new Font("arial",Font.BOLD,40)); g.drawString("Press Space to Start!!!", 225, 300); } //结束语句 if(!isEnd == false) { g.setColor(Color.RED); g.setFont(new Font("arial",Font.BOLD,40)); g.drawString("END: Press Space to Restart!!!", 175, 300); } //画蛇头 switch (fx) { case "R": right.paintIcon(this, g, snakex[0], snakey[0]); break; case "L": left.paintIcon(this, g, snakex[0], snakey[0]); break; case "U": up.paintIcon(this, g, snakex[0], snakey[0]); break; case "D": down.paintIcon(this, g, snakex[0], snakey[0]); break; } //食物 food.paintIcon(this, g, foodx, foody); //循环画出蛇身体 for(int i=1; i<len; i++) { body.paintIcon(this, g, snakex[i], snakey[i]); } } @Override public void keyTyped(KeyEvent e) { } //监听按下空格键 @Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if(keyCode == KeyEvent.VK_SPACE) { if(isEnd) {//重新开始 isEnd = !isEnd; initsnake(); }else { isStared = !isStared; } repaint(); }else if(keyCode == KeyEvent.VK_RIGHT) { fx = "R"; }else if(keyCode == KeyEvent.VK_LEFT) { fx = "L"; }else if(keyCode == KeyEvent.VK_UP) { fx = "U"; }else if(keyCode == KeyEvent.VK_DOWN) { fx = "D"; } } @Override public void keyReleased(KeyEvent e) { } //移动蛇 @Override public void actionPerformed(ActionEvent e) { //实现空格暂停 if(isStared && !isEnd) { //画蛇身体 for(int i=len-1; i>0; i--) { snakex[i] = snakex[i-1]; snakey[i] = snakey[i-1]; } //画蛇头 //实现头的移动 switch (fx) { case "R": snakex[0] = snakex[0] + 25; if(snakex[0] >850) isEnd = !isEnd;//当蛇到边界时,重新开始 break; case "L": snakex[0] = snakex[0] - 25; if(snakex[0] <25) isEnd = !isEnd; break; case "U": snakey[0] = snakey[0] - 25; if(snakey[0] <75) isEnd = !isEnd; break; case "D": snakey[0] = snakey[0] + 25; if(snakey[0] >650) isEnd = !isEnd; break; } //蛇吃食物长大 if(snakex[0] == foodx && snakey[0] == foody) { len++; score +=10; speed -=30; foodx = 25 + 25*rand.nextInt(34); foody = 75 + 25*rand.nextInt(24); } //检测蛇是否重叠 for(int i=1; i<len; i++) { if(snakex[i] == snakex[0] && snakey[i] == snakey[0]) { isEnd = !isEnd; } } repaint(); } timer.start(); } }
JAVA风景日历,运行时,日历是有了,但风景没有,这是为什么?
运行是这样 ![图片说明](https://img-ask.csdn.net/upload/201911/14/1573703884_780623.jpg) 但是想要这样![图片说明](https://img-ask.csdn.net/upload/201911/14/1573708341_322515.jpg) ``` import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.*; import java.util.Timer; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; //这是一个用JList和JTable完成的简单日历 public class calender { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new CalendarFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); } } class CalendarFrame extends JFrame { private static final long serialVersionUID = 8067844586793608064L; JPanel listPanel; // 显示月份的列表面板 JPanel tablePanel; // 显示日期的表格面板 JPanel textPanel; // 文本面板 JMenuBar menuBar; // JMenuBar,JMenu定义的变量都没有实现功能 JMenu fileMenu; JMenu editMenu; JMenu formatMenu; JMenu lookMenu; JMenu helpMenu; JEditorPane text; // 自带复制,剪切和删除快捷键功能的面板 JScrollPane textscrollpane; JScrollPane tablescrollpane; @SuppressWarnings("rawtypes") JList list; // 显示月份的列表 JTable table; // 显示日期的表格 JPanel yearPanel; // 显示年份的面板 JSpinner spinner; // JSpinner空间 JLabel label = new JLabel(); public static boolean flag = true; @SuppressWarnings({ "unchecked", "rawtypes" }) public CalendarFrame() { table = new JTable(new MyTableModel()); tablescrollpane = new JScrollPane(table); for (int i = 0; i < 7; i++) { TableColumn column = table.getColumnModel().getColumn(i);// 获取表格每一列 column.setResizable(false);// 不允许改变列的大小 } table.setBackground(Color.GREEN); table.setRowHeight(72); // 设定每列的大小 table.setRowSelectionAllowed(false);// 设定行的选择模式 table.setDefaultRenderer(String.class, new MyTableRenderer()); list = new JList(new AbstractListModel() // 匿名的list模型类,提供list显示的月份数据 { private static final long serialVersionUID = -3703164069291737586L; public Object getElementAt(int index) { String obj = null; switch (index) { case 0: obj = "Jan"; break; case 1: obj = "Feb"; break; case 2: obj = "Mar"; break; case 3: obj = "Apr"; break; case 4: obj = "May"; break; case 5: obj = "Jun"; break; case 6: obj = "Jul"; break; case 7: obj = "Aug"; break; case 8: obj = "Sep"; break; case 9: obj = "Oct"; break; case 10: obj = "Nov"; break; case 11: obj = "Dec"; break; } return obj; } @Override public int getSize() { return 12; } }); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 设定列表的选择模式 list.setCellRenderer(new MyListCellRenderer()); // 列表元素的绘制类MyListCellRenderer list.setSelectedIndex(Calendar.getInstance().get(Calendar.MONTH));// JList默认的月份为现实的月份 list.addListSelectionListener(new ListSelectionListener()// 当某个列表被选中时,更新日期table控件 { public void valueChanged(ListSelectionEvent e) { flag = true; table.updateUI(); } }); list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { String s = (String) list.getSelectedValue(); JOptionPane.showMessageDialog(list, s); } } }); listPanel = new JPanel(); listPanel.setLayout(new BorderLayout()); listPanel.add(list); tablePanel = new JPanel(); tablePanel.setBackground(Color.white); tablePanel.setLayout(new BorderLayout()); tablePanel.add(tablescrollpane); // table.setBackground(Color.green); yearPanel = new JPanel();// 将label控件和JSpinner控件加入年份面板上 yearPanel.setLayout(new GridLayout(0, 4)); JLabel gongyuan = new JLabel("公元", JLabel.RIGHT); JLabel year = new JLabel("年"); spinner = new JSpinner(new SpinnerNumberModel(Calendar.getInstance() .get(Calendar.YEAR), null, null, 1)); spinner.addChangeListener(new ChangeListener() // 为JSpinner空间添加事件监听器 { @Override public void stateChanged(ChangeEvent e) { flag = true; table.updateUI(); } }); yearPanel.add(gongyuan); yearPanel.add(spinner); yearPanel.add(year); yearPanel.add(label); showTime(); new Timer().schedule(new TimerTask() { @Override public void run() { while (true) { showTime(); } } }, 1000); tablePanel.add(yearPanel, BorderLayout.NORTH);// 将年份面板加入到表格面板的北部 textPanel = new JPanel(); textPanel.setLayout(new BorderLayout()); text = new JEditorPane(); textscrollpane = new JScrollPane(text); textPanel.add(textscrollpane); text.setFont(new Font("SansSerif", Font.PLAIN, 40)); tablePanel.add(textPanel, BorderLayout.SOUTH); menuBar = new JMenuBar();// JMenu定义的空间都没实现功能 fileMenu = new JMenu("文件"); editMenu = new JMenu("编辑"); formatMenu = new JMenu("格式"); lookMenu = new JMenu("查看"); helpMenu = new JMenu("帮助"); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(formatMenu); menuBar.add(lookMenu); menuBar.add(helpMenu); GridBagLayout layout = new GridBagLayout(); // 设成GridBagLayout布局 GridBagConstraints constraints = new GridBagConstraints(); this.setFont(new Font("SansSerif", Font.PLAIN, 14)); this.setLayout(layout); this.setTitle("风景日历"); // 设定标题 this.setIconImage(new ImageIcon("res\\title.jpg").getImage()); // 设定图标 constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 0.5; constraints.weighty = 0.5; layout.setConstraints(listPanel, constraints); constraints.weightx = 8.0; constraints.weighty = 0.5; layout.setConstraints(tablePanel, constraints); this.setJMenuBar(menuBar); this.add(listPanel); this.add(tablePanel); this.setSize(this.getToolkit().getScreenSize().width * 3 / 4, this .getToolkit().getScreenSize().height * 3 / 4); // 设定窗体的大小 } private void showTime() { int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); int minute = Calendar.getInstance().get(Calendar.MINUTE); int second = Calendar.getInstance().get(Calendar.SECOND); StringBuilder sb = new StringBuilder(); if (hour < 10) { sb.append("0" + hour); } else { sb.append(hour); } if (minute < 10) { sb.append(":0" + minute); } else { sb.append(":" + minute); } if (second < 10) { sb.append(":0" + second); } else sb.append(":" + second); label.setFont(new Font("SansSerif", Font.BOLD, 12)); label.setForeground(Color.BLACK); label.setText(sb.toString()); } class MyTableModel extends AbstractTableModel // 表格模型类,提供表格数据 { private static final long serialVersionUID = 1L; String[] columnName = new String[] // 表格列名 { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; @Override public int getColumnCount() // 返回表格列数 { return columnName.length; } public int getRowCount() // 返回表格行数 { return 6; } public String getColumnName(int col) // 获得表格列名 { return columnName[col]; } public Class<? extends Object> getColumnClass(int c) { return getValueAt(0, c).getClass(); } public Object getValueAt(int rowIndex, int columnIndex) { int month = list.getSelectedIndex();// 获得列表的月份 int year = (Integer) spinner.getValue();// 获得spinner显示的年份 GregorianCalendar gc = new GregorianCalendar(year, month, 1); int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK) - 1; // 获得这个月的第一天是星期几 int countDayInMonth = 0;// 某月的总天数,这里的月是从0-11,表示1-12月 if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11) { countDayInMonth = 31; // 是31天的月份 } else if (month == 3 || month == 5 || month == 8 || month == 10) { countDayInMonth = 30; // 是30天的月份 } else if (gc.isLeapYear(year) && month == 1) { countDayInMonth = 29; // 闰年2月 } else if (!gc.isLeapYear(year) && month == 1) { countDayInMonth = 28; // 非闰年2月 } String value = ""; // 因为返回值是Object类型,所以不能直接返回int类型的数据,所以转换成String类型 if (rowIndex == 0) // 第一列的数据 { if (columnIndex < dayOfWeek) { value = ""; } else { value = "" + (columnIndex - dayOfWeek + 1); } } else // 其余列的数据 { if (((rowIndex - 1) * 7) + (columnIndex + 1 + 7 - dayOfWeek) <= countDayInMonth) value = (((rowIndex - 1) * 7) + (columnIndex + 1 + 7 - dayOfWeek)) + ""; } return value; } } @SuppressWarnings("rawtypes") class MyListCellRenderer extends JLabel implements ListCellRenderer // 列表元素绘制类继承自JLabel,实现ListCellRenderer接口 { private static final long serialVersionUID = 1L; public Component getListCellRendererComponent(JList list, // the list Object value, // value to display int index, // cell index boolean isSelected, // is the cell selected boolean cellHasFocus) // does the cell have focus { String s = value.toString().trim(); // 获取选中元素的字符内容 setText(s); // 显示这个字符 Dimension dimension = list.getSize(); // 设定这个每个元素的大小 int height = dimension.height / 12; int width = dimension.width; setSize(width, height); if (isSelected) // 如果该元素被选中,则背景色为红色 { setBackground(Color.red); setForeground(list.getSelectionBackground()); } else // 未被选中的元素背景色显示为灰色,前景色为粉红色 { setBackground(Color.gray); setForeground(Color.pink); } setIcon(new ImageIcon("res\\mon.jpg")); // 设定该元素的图标 setEnabled(list.isEnabled()); setFont(new Font("SansSerif", Font.PLAIN, 20)); // 设定字体大小 setOpaque(true); return this; } } class MyTableRenderer extends JLabel implements TableCellRenderer { private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if ((Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "") // 如果这个标签上的值等于该天的值 .equals(value) && flag == true // 标记为true && list.getSelectedIndex() == Calendar.getInstance().get( Calendar.MONTH) // 列表显示的月份是该月的值 && (Integer) spinner.getValue() == Calendar.getInstance() .get(Calendar.YEAR))// spinner显示的年份是该年 { setFont(new Font("SansSerif", Font.PLAIN, 40)); // 设定字体大小 setText((String) value); // 显示日期字符串 setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); setForeground(Color.RED); // 设定字符串颜色 flag = false; } else // 如果不是改日的标签上的值 { setFont(new Font("SansSerif", Font.PLAIN, 40)); // 设定字体大小 setText((String) value); // 显示标签上的日期字符串 if (hasFocus) // 如果是被点中的表格的单元格 { setBorder(UIManager .getBorder("Table.focusCellHighlightBorder")); // 设定边框 setForeground(Color.RED);// 设定日期字符串颜色 } else { setForeground(null); setBorder(null); } } return this; } } } ```
我的Java贪吃蛇代码,为什么蛇不显示?
图片如下: (蓝色的是蛇,黄色的是食物) ![图片1](https://img-ask.csdn.net/upload/201910/15/1571144046_475523.png) ![图片2](https://img-ask.csdn.net/upload/201910/15/1571144080_341225.png) 代码如下: ``` java import java.awt.Color; import java.awt.Container; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.WindowConstants; public class SnakeGame extends JFrame{ String snake_dir=""; int snake_x=0; int snake_y=0; int bonus_x=10; int bonus_y=10; int score=1; int index=0; int snake[][]=new int[1024][2]; boolean started=false; boolean lose=false; boolean win=false; public void resetsnake(){ snake_dir=""; score=1; snake_x=0; snake_y=0; bonus_x=0; bonus_y=0; started=false; lose=false; index=0; snake=new int[1024][2]; } public Color color(int r,int g,int b){ Color col = new Color(r,g,b); return col; } public SnakeGame(String title){ class DrawPanel extends JPanel{ public void update_screen(Graphics g){ super.paint(g); g.setColor(color(0,0,0)); g.fillRect(0,0,900,600); g.setColor(color(255,255,0)); g.fillRect(bonus_x*20, bonus_y*20, 20, 20); g.setColor(color(0,0,255)); for(int i=0;i<=score;i++){ g.fillRect(snake[i][0]*20, snake[i][1]*20, 20, 20); } } } class MultiThread extends Thread{ public void run(){ while(started==true){ try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } switch(snake_dir){ case "up": snake_y--; break; case "down": snake_y++; break; case "left": snake_x--; break; case "right": snake_x++; break; } if(snake_x<0){ snake_x=0; snake_dir=""; } if(snake_x>44){ snake_x=44; snake_dir=""; } if(snake_y<0){ snake_y=0; snake_dir=""; } if(snake_y>29){ snake_y=29; snake_dir=""; } for(int i=0;i<score-1;i++){ snake[i]=snake[i+1]; } snake[score-1][0]=snake_x; snake[score-1][1]=snake_y; if(snake_x==bonus_x && snake_y==bonus_y){ bonus_x=(int)(Math.random()*45); bonus_y=(int)(Math.random()*30); score++; if(score==1024){ started=false; win=true; } } new DrawPanel().update_screen(getGraphics()); } } } addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent e){ int keyCode=e.getKeyCode(); if(started==true){ switch(keyCode){ case KeyEvent.VK_UP: snake_dir="up"; break; case KeyEvent.VK_DOWN: snake_dir="down"; break; case KeyEvent.VK_LEFT: snake_dir="left"; break; case KeyEvent.VK_RIGHT: snake_dir="right"; break; } }else if(started==false && lose==true){ lose=false; }else if(started==false && lose==false){ started=true; new MultiThread().start(); } } @Override public void keyReleased(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} }); setTitle(title); setSize(900,600); setResizable(false); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args){ new SnakeGame("Java贪吃蛇"); } } ```
后端接口和h5交互,复杂请求只有OPTIONS,然后就没有POST请求了,为何?
后端接口服务在跟h5交互的时候POST请求,复杂请求会有一次OPTIONS请求,但是小概率出现只有OPTIONS,然后就没有POST了,OPTIONS是返回正常的状态码,这种问题出现的原因是什么呢?目前貌似只有上传文件接口出现了该问题 ```java public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; response.setCharacterEncoding("UTF-8"); response.setContentType("application/json;charset=utf-8"); response.setHeader("Access-Control-Allow-Origin", "*"); // 允许的访问方法 response.setHeader("Access-Control-Allow-Methods","POST, GET, PUT, OPTIONS, DELETE, PATCH"); // Access-Control-Max-Age 用于 CORS 相关配置的缓存 response.setHeader("Access-Control-Max-Age", "86400"); response.setHeader("Access-Control-Allow-Headers","token,Origin, X-Requested-With, Content-Type, Accept"); if(HttpMethod.OPTIONS.name().equals(request.getMethod().toUpperCase())){ response.setStatus(HttpStatus.SC_NO_CONTENT); filterChain.doFilter(request,response); } boolean check = false; String token = request.getHeader("token"); if(StringUtils.isNotBlank(token)){ long mobile = redisProxy.getMobileByToken(token); if(mobile > 0){ // token验证成功 check = true; request.setAttribute(Constant.REQUEST_UM5, Md5Util.getMd5(mobile)); } } if(check){ filterChain.doFilter(request,response); }else { //验证不通过 返回需要登录的状态码 ResponseView responseView = new ResponseView(ResultType.NEED_LOGIN); String resultStr = JSON.toJSONString(responseView); PrintWriter writer = null; try { writer = response.getWriter(); writer.write(resultStr); writer.flush(); } catch (IOException e) { log.error("filter error:{}",e); }finally { if(writer != null ){ writer.close(); } } } } ```
重金求解,为什么我接收不到socket服务端返回的信息,代码如下,这个logger.debug("result:"result)为什么总是空,确认了服务端的确返回到了socket,怎样才能正确从socket取到值呢?
这是socket客户端代码 ``` import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class Client extends Thread { Socket socket = null; public String result = ""; public String in = ""; public Client(String host, int port, String in) { try { in = new String(in.getBytes(),"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.in = in; try { socket = new Socket(host, port); socket.setSoTimeout(1000); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // public void shutDown() throws IOException { // if (socket != null) { // synchronized (socket) { // socket.close(); // } // } // System.out.println("StopClose.shutDown() complete"); // } @Override public void run() { new sendMessThread().start(); super.run(); try { InputStream s = socket.getInputStream(); byte[] buf = new byte[1024]; int len = 0; while ((len = s.read(buf)) != -1) { System.out.println(new String(buf, 0, len)); } } catch (IOException e) { e.printStackTrace(); } } class sendMessThread extends Thread{ @Override public void run() { super.run(); Scanner scanner=null; OutputStream os= null; try { scanner=new Scanner(System.in); os= socket.getOutputStream(); // String in; // do { // in=scanner.next(); // os.write((""+in).getBytes()); // os.flush(); // } while (!in.equals("bye")); for(int i =0;i<1;i++) { os.write((""+in).getBytes()); os.flush(); } BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(),"GBK")); String str = ""; System.out.println("RESULT AS FOLLOWING:"); while ((str = rd.readLine()) != null) { System.out.println(str); } // str = rd.readLine(); Client.this.result = str; System.out.println("Client.this.result:"+Client.this.result); rd.close(); } catch (IOException e) { e.printStackTrace(); } scanner.close(); try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } public static void main(String[] args) { // Client clientTest=new Client("88.6.13.66", 13000); // Client clientTest=new Client("127.0.0.1", 1234,""); // clientTest.start(); } } ``` 这是调用的代码 ``` import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.sql.Connection; import java.sql.Types; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; public class FaceCheckManage { private final static String DB_ALIAS = "ALIAS";//数据源 private static final String TRXZONE = "trxZone";//输入|地区号 private static final String TYPE = "type";//输入|操作类型 add-注册 check-识别 del-删除 private static final String IMG = "img";//输入|人脸数据 private static final String ID = "id";//输入|编号 private static final String VALUE = "VALUE";//输出|转发数据 public String process(IWFEngine engine, WFActivity activity, WFData wfd, String wfName) throws ParamNotExistException, com.zjft.bpe.stdlib.exception.UnrecognizedScopeException { BizDataModule dm = wfd.getDataModule(); ZjLogger logger = LoggerUtil.getLog(dm.getChannelId(), dm.getTxCode()); ModuleUtil moduleUtil = new ModuleUtil(wfd, wfd.getDataModule(), activity, logger); String trxZone = moduleUtil.getParamValue(TRXZONE); logger.debug("trxZone:"+trxZone); String type = moduleUtil.getParamValue(TYPE); String imgBase64 = moduleUtil.getParamValue(IMG); String id = moduleUtil.getParamValue(ID); Connection conn = wfd.getTxConnection(moduleUtil.getParamValue(DB_ALIAS)); try { /*是否已注册*/ boolean registedFlag = isRegisted(id, conn, logger); if("add".equals(type)&&registedFlag==true) { CommonUtil.setResponseMsg("FFFFF", "用户已注册,请先删除人脸数据", moduleUtil); return "fail"; }else if(("check".equals(type)||"del".equals(type))&&registedFlag==false) { CommonUtil.setResponseMsg("FFFFF", "用户人脸数据未注册", moduleUtil); return "fail"; } } catch (Exception e) { logger.error("查询是否已注册发生异常",e); CommonUtil.setResponseMsg("FFFFF", "查询是否已注册发生异常", moduleUtil); return "fail"; } JSONObject sysParams = null;//系统参数列表 try { //获取人脸识别配置参数 sysParams = getSysParam(type,conn, logger); }catch (TradeException e) { CommonUtil.setResponseMsg("FFFFF", e.getMessage(), moduleUtil); return "fail"; } catch (Exception e) { logger.error("查询人脸识别系统参数发生异常",e); CommonUtil.setResponseMsg("FFFFF", "查询人脸识别系统参数发生异常", moduleUtil); return "fail"; } String ip = sysParams.getString("ip"); String url =sysParams.getString("url"); //组参数 JSONObject paramMap = new JSONObject(); if("add".equals(type)) { paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); paramMap.put("img1", imgBase64); paramMap.put("imgFace1", "50,60,100,120"); paramMap.put("hack1", 1); paramMap.put("customerAgreement", 1); String trxString = "10032"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); //新增参数 }else if("check".equals(type)) { paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); paramMap.put("img1", imgBase64); paramMap.put("imgFace1", "50,60,100,120"); paramMap.put("threshold", 0.001); paramMap.put("hack1", 1); String trxString = "10034"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); }else if("del".equals(type)){ paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); String trxString = "10035"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); try { totalString = new String(totalString.getBytes(),"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); }else { CommonUtil.setResponseMsg("FFFFF", "错误的操作类型", moduleUtil); return "fail"; } String param = paramMap.toJSONString(); try { param = "params="+URLEncoder.encode(param,"UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("转换为请求数据失败"); return "fail"; } return "ok"; } /** * <p> 函数名:isRegisted </p> * <p> 函数功能:查询该编号用户人脸信息是否已注册 </p> * <p> 处理过程:(描述这个方法的处理逻辑)</p> * <p> 输入参数描述: </p> * <p> 输出参数描述: </p> * <p> 异常处理描述: </p> * <p> 创建信息:liuyuan/2019年6月4日 下午3:29:48/versoin</p> * <p> 修改信息:(修改人名、修改人名.../最后修改时间/修改版本号)</p> * <p> 多个版本修改,则每次新增一行修改信息</p> * @throws Exception */ private boolean isRegisted(String id,Connection conn,ZjLogger logger) throws Exception { String sql = "select t.id from USER_FACE_RECORD t where t.id_number=? or t.user_no=?"; List<SQLPara> sqlParas = new ArrayList<>(); sqlParas.add(new SQLPara("id_number", Types.VARCHAR, id)); sqlParas.add(new SQLPara("user_no", Types.VARCHAR, id)); CachedRowSet rlt = DbOperate.executeQueryByParamName(sql, sqlParas, conn, logger); return rlt.next(); } /** * * <p>Title: getSysParam</p> * <p>Description: 查询人脸识别相关参数 </p> * @param type * @param conn * @param logger * @return * @throws TradeException * @throws Exception */ private JSONObject getSysParam(String type,Connection conn, ZjLogger logger) throws TradeException,Exception { JSONObject sysParam = new JSONObject(); String qrySysParamSQL = " select t.param_value from SYS_PARAM t where t.param_name=? "; List<SQLPara> sqlParas = new ArrayList<>(); // 查询ip sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_ip")); CachedRowSet ipRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!ipRlt.next()) { throw new TradeException("请先配置人脸识别服务器地址(faceCheck_ip)"); } sysParam.put("ip",ipRlt.getString("param_value")); sqlParas.clear(); // 查询url sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_url")); CachedRowSet urlRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!urlRlt.next()) { throw new TradeException("请先配置人脸识别转发url(faceCheck_url)"); } sysParam.put("url",urlRlt.getString("param_value")); sqlParas.clear(); // 查询baseFlag sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_baseFlag")); CachedRowSet baseFlagRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!baseFlagRlt.next()) { throw new TradeException("请先配置人脸识基准照标示(faceCheck_baseFlag)"); } sysParam.put("baseFlag",baseFlagRlt.getInt("param_value")); sqlParas.clear(); // 查询threshold sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_threshold")); CachedRowSet thresholdRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!thresholdRlt.next()) { throw new TradeException("请先配置人脸识误识率阈值(faceCheck_threshold)"); } sysParam.put("threshold",thresholdRlt.getString("param_value")); sqlParas.clear(); //查询channel sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_channel")); CachedRowSet channelRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!channelRlt.next()) { throw new TradeException("请先配置人脸识别转发业务渠道编号(faceCheck_channel)"); } sysParam.put("channel",channelRlt.getString("param_value")); sqlParas.clear(); //交易编号写死,加操作类型大写进行区分 sysParam.put("trCode","SXFH-BF-SWXJ-ITMS-FACE-"+type.toUpperCase()); //查询appName sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_appName")); CachedRowSet appNameRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!appNameRlt.next()) { throw new TradeException("请先配置人脸识别应用名(faceCheck_appName)"); } sysParam.put("appName",appNameRlt.getString("param_value")); sqlParas.clear(); //查询appInfo sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_appInfo")); CachedRowSet appInfoRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!appInfoRlt.next()) { throw new TradeException("请先配置人脸识别客户端APP信息(faceCheck_appInfo)"); } sysParam.put("appInfo",appInfoRlt.getString("param_value")); sqlParas.clear(); //查询retentionTime sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_retentionTime")); CachedRowSet retentionTimeRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!retentionTimeRlt.next()) { throw new TradeException("请先配置人脸识清理时间(faceCheck_retentionTime)"); } sysParam.put("retentionTime",retentionTimeRlt.getString("param_value")); sqlParas.clear(); logger.debug("sysParam:"+sysParam); return sysParam; } public String getLenString (int length) { NumberFormat formatter = NumberFormat.getNumberInstance(); formatter.setMinimumIntegerDigits(5); formatter.setGroupingUsed(false); String lenString = formatter.format(length); return lenString; } } ``` 这个地方为什么总是空的 ![图片说明](https://img-ask.csdn.net/upload/201912/12/1576144606_651895.png)
HTTP Status 500 – Internal Server Error(jspmaker生成,tomcat实现)
内容是用Jspmaker把数据库表生成jsp,然后用tomcat,结果出现了以下问题 网站报错代码如下: HTTP Status 500 – Internal Server ErrorType 异常报告 消息 在 [146] 行处理 [/jspmoon/customerlist.jsp] 时发生异常 描述 服务器遇到一个意外的情况,阻止它完成请求。 Exception org.apache.jasper.JasperException: 在 [146] 行处理 [/jspmoon/customerlist.jsp] 时发生异常 143: // Open Connection to the database 144: try{ 145: Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 146: ResultSet rs = null; 147: // Build SQL 148: String strsql = "SELECT * FROM `customer`"; 149: whereClause = ""; Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:617) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:514) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) Root Cause java.lang.NullPointerException org.apache.jsp.jspmoon.customerlist_jsp._jspService(customerlist_jsp.java:585) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ):注意 主要问题的全部 stack 信息可以在 server logs 里查看 Apache Tomcat/8.5.50 jsp代码: <%@ page session="true" buffer="16kb" import="java.sql.*,java.util.*,java.text.*"%> <%@ page contentType="text/html; charset=UTF-8" %> <% response.setDateHeader("Expires", 0); // date in the past response.addHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // HTTP/1.1 response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.addHeader("Pragma", "no-cache"); // HTTP/1.0 %> <% Locale locale = Locale.getDefault(); response.setLocale(locale);%> <% session.setMaxInactiveInterval(30*60); %> <%@ include file="db.jsp" %> <%@ include file="jspmkrfn.jsp" %> <% int displayRecs = 20; int recRange = 10; %> <% String tmpfld = null; String escapeString = "\\\\'"; String dbwhere = ""; String masterdetailwhere = ""; String searchwhere = ""; String a_search = ""; String b_search = ""; String whereClause = ""; int startRec = 0, stopRec = 0, totalRecs = 0, recCount = 0; %> <% // Get search criteria for basic search String pSearch = request.getParameter("psearch"); String pSearchType = request.getParameter("psearchtype"); if (pSearch != null && pSearch.length() > 0) { pSearch = pSearch.replaceAll("'",escapeString); if (pSearchType != null && pSearchType.length() > 0) { while (pSearch.indexOf(" ") > 0) { pSearch = pSearch.replaceAll(" ", " "); } String [] arpSearch = pSearch.trim().split(" "); for (int i = 0; i < arpSearch.length; i++){ String kw = arpSearch[i].trim(); b_search = b_search + "("; b_search = b_search + "`C_NAME` LIKE '%" + kw + "%' OR "; b_search = b_search + "`C_ADDRESS` LIKE '%" + kw + "%' OR "; b_search = b_search + "`C_PHONE` LIKE '%" + kw + "%' OR "; b_search = b_search + "`C_MATSEGMENT` LIKE '%" + kw + "%' OR "; b_search = b_search + "`C_COMMENT` LIKE '%" + kw + "%' OR "; if (b_search.substring(b_search.length()-4,b_search.length()).equals(" OR ")) { b_search = b_search.substring(0,b_search.length()-4);} b_search = b_search + ") " + pSearchType + " "; } }else{ b_search = b_search + "`C_NAME` LIKE '%" + pSearch + "%' OR "; b_search = b_search + "`C_ADDRESS` LIKE '%" + pSearch + "%' OR "; b_search = b_search + "`C_PHONE` LIKE '%" + pSearch + "%' OR "; b_search = b_search + "`C_MATSEGMENT` LIKE '%" + pSearch + "%' OR "; b_search = b_search + "`C_COMMENT` LIKE '%" + pSearch + "%' OR "; } } if (b_search.length() > 4 && b_search.substring(b_search.length()-4,b_search.length()).equals(" OR ")) {b_search = b_search.substring(0, b_search.length()-4);} if (b_search.length() > 5 && b_search.substring(b_search.length()-5,b_search.length()).equals(" AND ")) {b_search = b_search.substring(0, b_search.length()-5);} %> <% // Build search criteria if (a_search != null && a_search.length() > 0) { searchwhere = a_search; // Advanced search }else if (b_search != null && b_search.length() > 0) { searchwhere = b_search; // Basic search } // Save search criteria if (searchwhere != null && searchwhere.length() > 0) { session.setAttribute("customer_searchwhere", searchwhere); startRec = 1; // Reset start record counter (new search) session.setAttribute("customer_REC", new Integer(startRec)); }else{ if (session.getAttribute("customer_searchwhere") != null) searchwhere = (String) session.getAttribute("customer_searchwhere"); } %> <% // Get clear search cmd startRec = 0; if (request.getParameter("cmd") != null && request.getParameter("cmd").length() > 0) { String cmd = request.getParameter("cmd"); if (cmd.toUpperCase().equals("RESET")) { searchwhere = ""; // Reset search criteria session.setAttribute("customer_searchwhere", searchwhere); }else if (cmd.toUpperCase().equals("RESETALL")) { searchwhere = ""; // Reset search criteria session.setAttribute("customer_searchwhere", searchwhere); } startRec = 1; // Reset start record counter (reset command) session.setAttribute("customer_REC", new Integer(startRec)); } // Build dbwhere if (masterdetailwhere != null && masterdetailwhere.length() > 0) { dbwhere = dbwhere + "(" + masterdetailwhere + ") AND "; } if (searchwhere != null && searchwhere.length() > 0) { dbwhere = dbwhere + "(" + searchwhere + ") AND "; } if (dbwhere != null && dbwhere.length() > 5) { dbwhere = dbwhere.substring(0, dbwhere.length()-5); // Trim rightmost AND } %> <% // Load Default Order String DefaultOrder = ""; String DefaultOrderType = ""; // No Default Filter String DefaultFilter = ""; // Check for an Order parameter String OrderBy = request.getParameter("order"); if (OrderBy != null && OrderBy.length() > 0) { if (session.getAttribute("customer_OB") != null && ((String) session.getAttribute("customer_OB")).equals(OrderBy)) { // Check if an ASC/DESC toggle is required if (((String) session.getAttribute("customer_OT")).equals("ASC")) { session.setAttribute("customer_OT", "DESC"); }else{ session.setAttribute("customer_OT", "ASC"); } }else{ session.setAttribute("customer_OT", "ASC"); } session.setAttribute("customer_OB", OrderBy); session.setAttribute("customer_REC", new Integer(1)); }else{ OrderBy = (String) session.getAttribute("customer_OB"); if (OrderBy == null || OrderBy.length() == 0) { OrderBy = DefaultOrder; session.setAttribute("customer_OB", OrderBy); session.setAttribute("customer_OT", DefaultOrderType); } } // Open Connection to the database try{ Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = null; // Build SQL String strsql = "SELECT * FROM `customer`"; whereClause = ""; if (DefaultFilter.length() > 0) { whereClause = whereClause + "(" + DefaultFilter + ") AND "; } if (dbwhere.length() > 0) { whereClause = whereClause + "(" + dbwhere + ") AND "; } if (whereClause.length() > 5 && whereClause.substring(whereClause.length()-5, whereClause.length()).equals(" AND ")) { whereClause = whereClause.substring(0, whereClause.length()-5); } if (whereClause.length() > 0) { strsql = strsql + " WHERE " + whereClause; } if (OrderBy != null && OrderBy.length() > 0) { strsql = strsql + " ORDER BY `" + OrderBy + "` " + (String) session.getAttribute("customer_OT"); } //out.println(strsql); rs = stmt.executeQuery(strsql); rs.last(); totalRecs = rs.getRow(); rs.beforeFirst(); startRec = 0; int pageno = 0; // Check for a START parameter if (request.getParameter("start") != null && Integer.parseInt(request.getParameter("start")) > 0) { startRec = Integer.parseInt(request.getParameter("start")); session.setAttribute("customer_REC", new Integer(startRec)); }else if (request.getParameter("pageno") != null && Integer.parseInt(request.getParameter("pageno")) > 0) { pageno = Integer.parseInt(request.getParameter("pageno")); if (IsNumeric(request.getParameter("pageno"))) { startRec = (pageno-1)*displayRecs+1; if (startRec <= 0) { startRec = 1; }else if (startRec >= ((totalRecs-1)/displayRecs)*displayRecs+1) { startRec = ((totalRecs-1)/displayRecs)*displayRecs+1; } session.setAttribute("customer_REC", new Integer(startRec)); }else { startRec = ((Integer) session.getAttribute("customer_REC")).intValue(); if (startRec <= 0) { startRec = 1; // Reset start record counter session.setAttribute("customer_REC", new Integer(startRec)); } } }else{ if (session.getAttribute("customer_REC") != null) startRec = ((Integer) session.getAttribute("customer_REC")).intValue(); if (startRec==0) { startRec = 1; //Reset start record counter session.setAttribute("customer_REC", new Integer(startRec)); } } %> <%@ include file="header.jsp" %> <p><span class="jspmaker">TABLE: customer</span></p> <form action="customerlist.jsp"> <table border="0" cellspacing="0" cellpadding="4"> <tr> <td><span class="jspmaker">Quick Search (*)</span></td> <td><span class="jspmaker"> <input type="text" name="psearch" size="20"> <input type="Submit" name="Submit" value="GO"> &nbsp;&nbsp;<a href="customerlist.jsp?cmd=reset">Show all</a> </span></td> </tr> <tr><td>&nbsp;</td><td><span class="jspmaker"><input type="radio" name="psearchtype" value="" checked>Exact phrase&nbsp;&nbsp;<input type="radio" name="psearchtype" value="AND">All words&nbsp;&nbsp;<input type="radio" name="psearchtype" value="OR">Any word</span></td></tr> </table> </form> <form method="post"> <table border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC"> <tr bgcolor="#594FBF"> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_CUSTKEY","UTF-8") %>" style="color: #FFFFFF;">C CUSTKEY&nbsp;<% if (OrderBy != null && OrderBy.equals("C_CUSTKEY")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_NAME","UTF-8") %>" style="color: #FFFFFF;">C NAME&nbsp;(*)<% if (OrderBy != null && OrderBy.equals("C_NAME")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_ADDRESS","UTF-8") %>" style="color: #FFFFFF;">C ADDRESS&nbsp;(*)<% if (OrderBy != null && OrderBy.equals("C_ADDRESS")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_NATIONKEY","UTF-8") %>" style="color: #FFFFFF;">C NATIONKEY&nbsp;<% if (OrderBy != null && OrderBy.equals("C_NATIONKEY")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_PHONE","UTF-8") %>" style="color: #FFFFFF;">C PHONE&nbsp;(*)<% if (OrderBy != null && OrderBy.equals("C_PHONE")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_ACCTBAL","UTF-8") %>" style="color: #FFFFFF;">C ACCTBAL&nbsp;<% if (OrderBy != null && OrderBy.equals("C_ACCTBAL")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_MATSEGMENT","UTF-8") %>" style="color: #FFFFFF;">C MATSEGMENT&nbsp;(*)<% if (OrderBy != null && OrderBy.equals("C_MATSEGMENT")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td><span class="jspmaker" style="color: #FFFFFF;"> <a href="customerlist.jsp?order=<%= java.net.URLEncoder.encode("C_COMMENT","UTF-8") %>" style="color: #FFFFFF;">C COMMENT&nbsp;(*)<% if (OrderBy != null && OrderBy.equals("C_COMMENT")) { %><span class="ewTableOrderIndicator"><% if (((String) session.getAttribute("customer_OT")).equals("ASC")) {%>5<% }else if (((String) session.getAttribute("customer_OT")).equals("DESC")) { %>6<% } %></span><% } %></a> </span></td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <% // Avoid starting record > total records if (startRec > totalRecs) { startRec = totalRecs; } // Set the last record to display stopRec = startRec + displayRecs - 1; // Move to first record directly for performance reason recCount = startRec - 1; if (rs.next()) { rs.first(); rs.relative(startRec - 1); } long recActual = 0; if (startRec == 1) rs.beforeFirst(); else rs.previous(); while (rs.next() && recCount < stopRec) { recCount++; if (recCount >= startRec) { recActual++; %> <% String bgcolor = "#FFFFFF"; // Set row color %> <% if (recCount%2 != 0) { // Display alternate color for rows bgcolor = "#F5F5F5"; } %> <% String x_C_CUSTKEY = ""; String x_C_NAME = ""; String x_C_ADDRESS = ""; String x_C_NATIONKEY = ""; String x_C_PHONE = ""; String x_C_ACCTBAL = ""; String x_C_MATSEGMENT = ""; String x_C_COMMENT = ""; // Load Key for record String key = ""; key = String.valueOf(rs.getLong("C_CUSTKEY")); // C_CUSTKEY x_C_CUSTKEY = String.valueOf(rs.getLong("C_CUSTKEY")); // C_NAME if (rs.getString("C_NAME") != null){ x_C_NAME = rs.getString("C_NAME"); }else{ x_C_NAME = ""; } // C_ADDRESS if (rs.getString("C_ADDRESS") != null){ x_C_ADDRESS = rs.getString("C_ADDRESS"); }else{ x_C_ADDRESS = ""; } // C_NATIONKEY x_C_NATIONKEY = String.valueOf(rs.getLong("C_NATIONKEY")); // C_PHONE if (rs.getString("C_PHONE") != null){ x_C_PHONE = rs.getString("C_PHONE"); }else{ x_C_PHONE = ""; } // C_ACCTBAL x_C_ACCTBAL = String.valueOf(rs.getDouble("C_ACCTBAL")); // C_MATSEGMENT if (rs.getString("C_MATSEGMENT") != null){ x_C_MATSEGMENT = rs.getString("C_MATSEGMENT"); }else{ x_C_MATSEGMENT = ""; } // C_COMMENT if (rs.getString("C_COMMENT") != null){ x_C_COMMENT = rs.getString("C_COMMENT"); }else{ x_C_COMMENT = ""; } %> <tr bgcolor="<%= bgcolor %>"> <td><span class="jspmaker"><% out.print(x_C_CUSTKEY); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_NAME); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_ADDRESS); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_NATIONKEY); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_PHONE); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_ACCTBAL); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_MATSEGMENT); %></span>&nbsp;</td> <td><span class="jspmaker"><% out.print(x_C_COMMENT); %></span>&nbsp;</td> <td><span class="jspmaker"><a href="<% key = rs.getString("C_CUSTKEY"); if (key != null && key.length() > 0) { out.print("customerview.jsp?key=" + java.net.URLEncoder.encode(key,"UTF-8")); }else{ out.print("javascript:alert('Invalid Record! Key is null');"); } %>">View</a></span></td> <td><span class="jspmaker"><a href="<% key = rs.getString("C_CUSTKEY"); if (key != null && key.length() > 0) { out.print("customeredit.jsp?key=" + java.net.URLEncoder.encode(key,"UTF-8")); }else{ out.print("javascript:alert('Invalid Record! Key is null');"); } %>">Edit</a></span></td> <td><span class="jspmaker"><a href="<% key = rs.getString("C_CUSTKEY"); if (key != null && key.length() > 0) { out.print("customeradd.jsp?key=" + java.net.URLEncoder.encode(key,"UTF-8")); }else{ out.print("javascript:alert('Invalid Record! Key is null');"); } %>">Copy</a></span></td> <td><span class="jspmaker"><a href="<% key = rs.getString("C_CUSTKEY"); if (key != null && key.length() > 0) { out.print("customerdelete.jsp?key=" + java.net.URLEncoder.encode(key,"UTF-8")); }else{ out.print("javascript:alert('Invalid Record! Key is null');"); } %>">Delete</a></span></td> </tr> <% // } } } %> </table> </form> <% // Close recordset and connection rs.close(); rs = null; stmt.close(); stmt = null; conn.close(); conn = null; }catch(SQLException ex){ out.println(ex.toString()); } %> <table border="0" cellspacing="0" cellpadding="10"><tr><td> <% boolean rsEof = false; if (totalRecs > 0) { rsEof = (totalRecs < (startRec + displayRecs)); int PrevStart = startRec - displayRecs; if (PrevStart < 1) { PrevStart = 1;} int NextStart = startRec + displayRecs; if (NextStart > totalRecs) { NextStart = startRec;} int LastStart = ((totalRecs-1)/displayRecs)*displayRecs+1; %> <form> <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="jspmaker">Page</span>&nbsp;</td> <!--first page button--> <% if (startRec==1) { %> <td><img src="images/firstdisab.gif" alt="First" width="20" height="15" border="0"></td> <% }else{ %> <td><a href="customerlist.jsp?start=1"><img src="images/first.gif" alt="First" width="20" height="15" border="0"></a></td> <% } %> <!--previous page button--> <% if (PrevStart == startRec) { %> <td><img src="images/prevdisab.gif" alt="Previous" width="20" height="15" border="0"></td> <% }else{ %> <td><a href="customerlist.jsp?start=<%=PrevStart%>"><img src="images/prev.gif" alt="Previous" width="20" height="15" border="0"></a></td> <% } %> <!--current page number--> <td><input type="text" name="pageno" value="<%=(startRec-1)/displayRecs+1%>" size="4"></td> <!--next page button--> <% if (NextStart == startRec) { %> <td><img src="images/nextdisab.gif" alt="Next" width="20" height="15" border="0"></td> <% }else{ %> <td><a href="customerlist.jsp?start=<%=NextStart%>"><img src="images/next.gif" alt="Next" width="20" height="15" border="0"></a></td> <% } %> <!--last page button--> <% if (LastStart == startRec) { %> <td><img src="images/lastdisab.gif" alt="Last" width="20" height="15" border="0"></td> <% }else{ %> <td><a href="customerlist.jsp?start=<%=LastStart%>"><img src="images/last.gif" alt="Last" width="20" height="15" border="0"></a></td> <% } %> <td><a href="customeradd.jsp"><img src="images/addnew.gif" alt="Add new" width="20" height="15" border="0"></a></td> <td><span class="jspmaker">&nbsp;of <%=(totalRecs-1)/displayRecs+1%></span></td> </td></tr></table> </form> <% if (startRec > totalRecs) { startRec = totalRecs;} stopRec = startRec + displayRecs - 1; recCount = totalRecs - 1; if (rsEof) { recCount = totalRecs;} if (stopRec > recCount) { stopRec = recCount;} %> <span class="jspmaker">Records <%= startRec %> to <%= stopRec %> of <%= totalRecs %></span> <% }else{ %> <span class="jspmaker">No records found</span> <p> <a href="customeradd.jsp"><img src="images/addnew.gif" alt="Add new" width="20" height="15" border="0"></a> </p> <% } %> </td></tr></table> <%@ include file="footer.jsp" %>
小白Android Studio代码运行后模拟器上只有Hello World!
``` package com.example.firstapp; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; import android.util.Log; import android.view.View; import java.util.Random; public class MyView extends View { MyThread mythread; private Paint paint;//画笔 private RectF rectF=new RectF(150,150,380,380); private int sweepAngle=0;//弧的当前度数 private int sweepAngleAdd=20;//每次弧增加的度数 private Random random=new Random(); private boolean running=true;//控制循环 public MyView(Context context, AttributeSet attrs){ super(context,attrs); init(context,attrs); } public MyView(Context context){ this(context,null); } private void init(Context context,AttributeSet attrs){ paint=new Paint(); paint.setTextSize(60); } protected void logic(){ sweepAngle+=sweepAngleAdd; //随机设置画笔颜色 int r=random.nextInt(255); int g=random.nextInt(255); int b=random.nextInt(255); paint.setARGB(255,r,g,b); if(sweepAngle>=360){ sweepAngle=0; } } private class MyThread extends Thread{ @Override public void run(){ while(running){ logic(); postInvalidate();//重新绘制会调用ondraw() try { Thread.sleep(200); }catch (InterruptedException e){ e.printStackTrace(); } } } } @Override protected void onDraw(Canvas canvas){ Log.i("MyView","onDraw"); if(mythread==null){ mythread=new MyThread(); mythread.start(); }else{ /* * 第一个参数:rectF 左上的坐标x,y,右下的坐标x,y * 第二个参数:弧形开始的角度 * 第三个参数:弧形结束的角度 * 第四个参数:true:画扇形,false:画弧线 * 第五个参数:画笔 * */ canvas.drawArc(rectF,0,sweepAngle,true,paint); } } @Override protected void onDetachedFromWindow(){ running=false; super.onDetachedFromWindow(); } } ``` 模拟器上只有Hello World,写的东西只有MyView类,是不是要加什么,还是代码有错
java web的jsp里text获取不到数据,只获取到null!求解,相关代码如下!
我屏蔽掉那里则能存到数据库,但是是null,已经填了东西上去了,如果不屏蔽的话输出“书名不能为空”,没有报错!System.out.println(sql);了一下是输出insert into book(bookname,bookauthor,bookpress,bookedition,booklocation) values('null','null',null,'null','null'),这要怎么解决,求大佬帮忙! //添加书本(控制部分) public boolean addBook(String bookname, String bookauthor, String bookpress,String bookedition,String booklocation) { Connection conn = null; Statement stmt = null; try { conn = Database.getConnection(); stmt = conn.createStatement(); String sql = "insert into book(bookname,bookauthor,bookpress,bookedition,booklocation) " + "values('"+bookname+"','"+bookauthor+"',"+bookpress+",'"+bookedition+"','"+booklocation+"')"; //System.out.println(sql); stmt.execute(sql); return true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } finally { Database.close(conn, stmt); } } //用的是servlet的doget和dopost,下面为servlet部分 String bookname = request.getParameter("bookname");//初始化图书的各个字段 String bookauthor = request.getParameter("bookauthor"); String bookpress = request.getParameter("bookpress"); String bookedition = request.getParameter("bookedition"); String booklocation = request.getParameter("booklocation"); // if(bookname==null||bookname.trim().isEmpty()){ // request.setAttribute("msg", "书名不能为空"); // request.getRequestDispatcher("/addbook.jsp").forward(request, response); // return; // } // if(bookauthor==null||bookauthor.trim().isEmpty()){ // request.setAttribute("msg", "作者不能为空"); // request.getRequestDispatcher("/addbook.jsp").forward(request, response); // return; // } // if(bookpress==null||bookpress.trim().isEmpty()){ // request.setAttribute("msg", "出版社不能为空"); // request.getRequestDispatcher("/addbook.jsp").forward(request, response); // return; // } // if(bookedition==null||bookedition.trim().isEmpty()){ // request.setAttribute("msg", "版本不能为空"); // request.getRequestDispatcher("/addbook.jsp").forward(request, response); // return; // } // if(booklocation==null||booklocation.trim().isEmpty()){ // request.setAttribute("msg", "出版存放位置不能为空"); // request.getRequestDispatcher("/addbook.jsp").forward(request, response); // return; // } Operator operate = new Operator(); boolean isSuccess = operate.addBook(bookname, bookauthor, bookpress, bookedition,booklocation); if(isSuccess){ request.setAttribute("msg", "增加成功"); request.getRequestDispatcher("/addbook.jsp").forward(request, response); return; }else{ request.setAttribute("msg", "增加失败"); request.getRequestDispatcher("/addbook.jsp").forward(request, response); return; } //下面是jsp部分 <form action="AddBookServlet" method="post" enctype="multipart/form-data"> <div> <input type="text" name="bookname" placeholder="请输入书名(如:三国演义)"></div> <div> <input type="text" name="bookauthor" placeholder="请输入作者(如:张三)"></div> <div> <input type="text" name="bookpress" placeholder="请输入出版社(如:中山大学出版社)"></div> <div> <input type="text" name="bookedition" placeholder="请输入版本(如:第一版)"></div> <div> <input type="text" name="booklocation" placeholder="请输入存放位置(如:1楼101室2019)"></div> <!-- <div> <a href="javascript:;" class="a-upload">点击这里上传文件(.txt文件) <input type="file" name="file" id="file"> </a></div> --> <div> <input type="submit" value="增加图书" id="addbook"> </div> <div> <a href="welcome.jsp" id="back">返回菜单</a></div></br> </form> <font color="red" size="2"> ${msg }</font>
java 多次嵌套数据,如何遍历获取到最内层的数据?
``` [ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U00-U49 对新发生的不明原因疾病的或紧急情况的临时安排", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U04 严重急性呼吸道综合征[SARS]", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U04.9 未特指的严重急性呼吸道综合征", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U04.9", "icdPid":"119f028c-7938-11e9-9611-8cec4bd010f3", "icdName":"未特指的严重急性呼吸道综合征", "icdId":"119f0307-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 } ], "isParent":"false", "level":2, "icdCode":"U04", "icdPid":"69b8458e-8034-11e9-b519-8cec4bd010f3", "icdName":"严重急性呼吸道综合征[SARS]", "icdId":"119f028c-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06 紧急使用U06", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.0 紧急使用U06.0", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.0", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.0", "icdId":"119f047b-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.1 紧急使用U06.1", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.1", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.1", "icdId":"119f04f6-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.2 紧急使用U06.2", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.2", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.2", "icdId":"119f056d-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.3 紧急使用U06.3", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.3", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.3", "icdId":"119f05ec-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.4 紧急使用U06.4", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.4", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.4", "icdId":"119f0671-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.5 紧急使用U06.5", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.5", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.5", "icdId":"119f06e5-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.6 紧急使用U06.6", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.6", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.6", "icdId":"119f075c-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.7 紧急使用U06.7", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.7", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.7", "icdId":"119f07db-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.8 紧急使用U06.8", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.8", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.8", "icdId":"119f0852-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U06.9 紧急使用U06.9", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U06.9", "icdPid":"119f0404-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U06.9", "icdId":"119f08cd-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 } ], "isParent":"false", "level":2, "icdCode":"U06", "icdPid":"69b8458e-8034-11e9-b519-8cec4bd010f3", "icdName":"紧急使用U06", "icdId":"119f0404-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07 紧急使用U07", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.0 紧急使用U07.0", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.0", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.0", "icdId":"119f0a3a-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.1 紧急使用U07.1", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.1", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.1", "icdId":"119f0ab2-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.2 紧急使用U07.2", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.2", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.2", "icdId":"119f0b2d-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.3 紧急使用U07.3", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.3", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.3", "icdId":"119f0ba7-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.4 紧急使用U07.4", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.4", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.4", "icdId":"119f0c22-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.5 紧急使用U07.5", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.5", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.5", "icdId":"119f0c9a-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.6 紧急使用U07.6", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.6", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.6", "icdId":"119f0d15-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.7 紧急使用U07.7", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.7", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.7", "icdId":"119f0d90-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.8 紧急使用U07.8", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.8", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.8", "icdId":"119f0e0a-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U07.9 紧急使用U07.9", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U07.9", "icdPid":"119f09bf-7938-11e9-9611-8cec4bd010f3", "icdName":"紧急使用U07.9", "icdId":"119f0e96-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 } ], "isParent":"false", "level":2, "icdCode":"U07", "icdPid":"69b8458e-8034-11e9-b519-8cec4bd010f3", "icdName":"紧急使用U07", "icdId":"119f09bf-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 } ], "isParent":"true", "level":1, "icdCode":"U00-U49", "icdPid":"f514142c-795f-11e9-9611-8cec4bd010f3", "icdName":"对新发生的不明原因疾病的或紧急情况的临时安排", "icdId":"69b8458e-8034-11e9-b519-8cec4bd010f3", "open":"false", "codelength":0 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82-U85 对微生物和抗肿瘤药物产生的抗药性", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82 对β-内酰胺类抗生素耐药", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82.0 对青霉素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U82.0", "icdPid":"119f0f18-7938-11e9-9611-8cec4bd010f3", "icdName":"对青霉素耐药", "icdId":"119f0f93-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82.1 对甲氧苯青霉素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U82.1", "icdPid":"119f0f18-7938-11e9-9611-8cec4bd010f3", "icdName":"对甲氧苯青霉素耐药", "icdId":"119f1178-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82.2 对β-内酰胺(ESBL)类耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U82.2", "icdPid":"119f0f18-7938-11e9-9611-8cec4bd010f3", "icdName":"对β-内酰胺(ESBL)类耐药", "icdId":"119f144b-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82.8 对其他β-内酰胺类抗生素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U82.8", "icdPid":"119f0f18-7938-11e9-9611-8cec4bd010f3", "icdName":"对其他β-内酰胺类抗生素耐药", "icdId":"119f163e-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U82.9 对β-内酰胺类抗生素耐药,未特指", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U82.9", "icdPid":"119f0f18-7938-11e9-9611-8cec4bd010f3", "icdName":"对β-内酰胺类抗生素耐药,未特指", "icdId":"119f18a7-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 } ], "isParent":"false", "level":2, "icdCode":"U82", "icdPid":"69b852ad-8034-11e9-b519-8cec4bd010f3", "icdName":"对β-内酰胺类抗生素耐药", "icdId":"119f0f18-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83 对其他抗生素耐药", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83.0 对万古霉素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U83.0", "icdPid":"119f19a4-7938-11e9-9611-8cec4bd010f3", "icdName":"对万古霉素耐药", "icdId":"119f1a1c-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83.1 对其他与万古霉素有关的抗生素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U83.1", "icdPid":"119f19a4-7938-11e9-9611-8cec4bd010f3", "icdName":"对其他与万古霉素有关的抗生素耐药", "icdId":"119f1b85-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83.2 对喹诺酮耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U83.2", "icdPid":"119f19a4-7938-11e9-9611-8cec4bd010f3", "icdName":"对喹诺酮耐药", "icdId":"119f1c74-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83.7 对多种抗生素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U83.7", "icdPid":"119f19a4-7938-11e9-9611-8cec4bd010f3", "icdName":"对多种抗生素耐药", "icdId":"119f1d6d-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83.8 对其他单一指定抗生素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U83.8", "icdPid":"119f19a4-7938-11e9-9611-8cec4bd010f3", "icdName":"对其他单一指定抗生素耐药", "icdId":"119f1e63-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U83.9 对未特指的抗生素耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U83.9", "icdPid":"119f19a4-7938-11e9-9611-8cec4bd010f3", "icdName":"对未特指的抗生素耐药", "icdId":"119f1fef-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 } ], "isParent":"false", "level":2, "icdCode":"U83", "icdPid":"69b852ad-8034-11e9-b519-8cec4bd010f3", "icdName":"对其他抗生素耐药", "icdId":"119f19a4-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84 对其他抗菌药耐药", "partnum":"22", "children":[ { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.0 对抗寄生虫药物耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.0", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"对抗寄生虫药物耐药", "icdId":"119f216a-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.1 对抗真菌药物耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.1", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"对抗真菌药物耐药", "icdId":"119f2259-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.2 对抗病毒药物耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.2", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"对抗病毒药物耐药", "icdId":"119f237f-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.3 抗结核病药物耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.3", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"抗结核病药物耐药", "icdId":"119f2471-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.7 对多种抗菌药物耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.7", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"对多种抗菌药物耐药", "icdId":"119f25ec-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.8 对其他特指抗菌药耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.8", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"对其他特指抗菌药耐药", "icdId":"119f2704-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U84.9 对未特指的抗菌药物耐药", "partnum":"22", "isParent":"true", "level":3, "icdCode":"U84.9", "icdPid":"119f20ec-7938-11e9-9611-8cec4bd010f3", "icdName":"对未特指的抗菌药物耐药", "icdId":"119f2801-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":5 } ], "isParent":"false", "level":2, "icdCode":"U84", "icdPid":"69b852ad-8034-11e9-b519-8cec4bd010f3", "icdName":"对其他抗菌药耐药", "icdId":"119f20ec-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 }, { "isclinical":-1, "isusing":1, "mid":"", "remark":"", "className":"U85 对抗肿瘤药物耐药", "partnum":"22", "isParent":"false", "level":2, "icdCode":"U85", "icdPid":"69b852ad-8034-11e9-b519-8cec4bd010f3", "icdName":"对抗肿瘤药物耐药", "icdId":"119f297f-7938-11e9-9611-8cec4bd010f3", "open":"false", "codelength":3 } ], "isParent":"true", "level":1, "icdCode":"U82-U85", "icdPid":"f514142c-795f-11e9-9611-8cec4bd010f3", "icdName":"对微生物和抗肿瘤药物产生的抗药性", "icdId":"69b852ad-8034-11e9-b519-8cec4bd010f3", "open":"false", "codelength":0 } ] ``` ![图片说明](https://img-ask.csdn.net/upload/201911/23/1574521364_679491.png) 如图,获取最内层的children节点下的值。 ``` public static List<Map<String, Object>> getLastChildren(List<Map<String, Object>> list,String key) { List<Map<String, Object>> lastChildrenList = new ArrayList<Map<String,Object>>(); for(int i=0;i<list.size();i++) { Map<String,Object> map = list.get(i); /*判断是否存在key*/ boolean containsKey = map.containsKey(key); /*如果存在则继续遍历*/ if(containsKey && map.get(key)!= null) { List<Map<String, Object>> childrenList = (List<Map<String, Object>>) map.get(key); getLastChildren(childrenList,key); }else {/*如果不存在则获取到key值 返回数据*/ lastChildrenList.add(map); } } return lastChildrenList; } ```
websocket频繁发送大数据。
springboot项目,使用websocket持续给前端(vue)发送数据。但是会经常中断,不发数据了,记录在线人数的功能正常,如果有新的登录或者登出,后台正常显示。就是不发数据了,需要重启项目才会发数据。 ``` package com.smart.common.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.websocket.*; import javax.websocket.server.PathParam; import javax.websocket.server.ServerEndpoint; import java.io.IOException; import java.util.concurrent.CopyOnWriteArraySet; /** * @Description: websocket工具类, * flag表示身份标识: * bigScreen:大屏 * backSys:后台系统 */ @ServerEndpoint("/websocket/{flag}") @Component public class WebSocketUtils { private Logger logger = LoggerFactory.getLogger(getClass()); public static final String BIGSCREEN = "bigScreen"; //大屏 public static final String BACKSYS = "backSys"; //后台 //静态变量,用来记录当前在线连接数 private static int onlineCount = 0; //concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。 private static CopyOnWriteArraySet<WebSocketUtils> webSocketSet = new CopyOnWriteArraySet<>(); //与某个客户端的连接会话,需要通过它来给客户端发送数据 private Session session; /** * 身份标识 */ private String flag; /** * 连接建立成功调用的方法 * @param session 可选的参数。session为与某个客户端的连接会话,需要通过它来给客户端发送数据 */ @OnOpen public void onOpen(@PathParam("flag") String flag, Session session){ this.session = session; this.flag = flag; webSocketSet.add(this); addOnlineCount(); //在线数加1 logger.info("有新连接加入!当前在线人数为" + getOnlineCount()+",上线用户为:"+this.flag); } /** * 连接关闭调用的方法 */ @OnClose public void onClose(){ webSocketSet.remove(this); subOnlineCount(); //在线数减1 logger.info("有一连接关闭!当前在线人数为" + getOnlineCount()+",下线用户为:"+this.flag); } /** * 收到客户端消息后调用的方法 * @param message 客户端发送过来的消息 * @param session 可选的参数 */ @OnMessage public void onMessage(String message, Session session) { //解析message if(message==null){ session.getAsyncRemote().sendText("发送的消息不能为空"); }else{ } } /** * 发生错误时调用 * @param session * @param error */ @OnError public void onError(Session session, Throwable error){ logger.info("发生错误:"+error.getMessage()); error.printStackTrace(); } /** * 群发消息 * @param message * @throws IOException */ public void sendMessageToFlag(String message){ for (WebSocketUtils ws : webSocketSet){ try{ ws.sendMessage(message); }catch (Exception e){ logger.error("sendMessageToFlag: "+e.toString()); } } } /** * 给指定身份发送消息 * @param message * @param flag * @throws IOException */ public void sendMessageToFlag(String message,String flag){ try{ boolean online = true; for (WebSocketUtils ws : webSocketSet){ if (flag.equals(ws.flag)){ ws.sendMessage(message); online = false; } } if (online){ logger.info(flag+"不在线"); } }catch (Exception e){ logger.error("sendMessageToFlag: "+e.toString()); } } public boolean isonline(){ boolean online = false; for (WebSocketUtils ws : webSocketSet){ if (BIGSCREEN.equals(ws.flag)){ online = true; } } return online; } public void sendMessageToBigScreen(String message){ sendMessageToFlag(message,BIGSCREEN); } public void snedMessage2BackSys(String message){ sendMessageToFlag(message,BACKSYS); } /** * 服务器主动推送消息到客户端 * @param message * @throws IOException */ private void sendMessage(String message) throws IOException { synchronized(this.session){ this.session.getBasicRemote().sendText(message); } System.out.println("发送数据给:"+this.flag+":"+message); } private static synchronized int getOnlineCount() { return onlineCount; } private static synchronized void addOnlineCount() { WebSocketUtils.onlineCount++; } private static synchronized void subOnlineCount() { WebSocketUtils.onlineCount--; } } ```
这段代码加上main为什么会有四个线程
``` /* * 实体类 Thread * */ public class Ticket extends Thread{ private Integer num=100; private Object obj=new Object(); boolean flan=true; //重写Thread类的run方法供线程调用 public void run(){ while (flan){ synchronized(obj){ try {Thread.sleep(20); } catch (InterruptedException e) { e.printStackTrace(); } if (num>0){ System.out.println(Thread.currentThread().getName()+"..........."+num--); }else { flan=false; } } } } } ``` /* * 创建多线程 * */ public class Establish { public static void main(String args[]){ //方式一:继承Thread类 Ticket ticket=new Ticket(); Ticket ticket2=ticket; Ticket ticket3=ticket; // Ticket2 ticket2=new Ticket2(); Thread thread=new Thread(ticket); Thread thread2=new Thread(ticket2); Thread thread3=new Thread(ticket3); thread.start(); thread2.start(); ticket3.start(); } } 打印结果 ``` Thread-2...........35 Thread-2...........34 Thread-3...........33 Thread-3...........32 Thread-3...........31 Thread-3...........30 ```
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
JDK12 Collectors.teeing 你真的需要了解一下
前言 在 Java 12 里面有个非常好用但在官方 JEP 没有公布的功能,因为它只是 Collector 中的一个小改动,它的作用是 merge 两个 collector 的结果,这句话显得很抽象,老规矩,我们先来看个图(这真是一个不和谐的图????): 管道改造经常会用这个小东西,通常我们叫它「三通」,它的主要作用就是将 downstream1 和 downstre...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
GitHub标星近1万:只需5秒音源,这个网络就能实时“克隆”你的声音
作者 | Google团队 译者 | 凯隐 编辑 | Jane 出品 | AI科技大本营(ID:rgznai100) 本文中,Google 团队提出了一种文本语音合成(text to speech)神经系统,能通过少量样本学习到多个不同说话者(speaker)的语音特征,并合成他们的讲话音频。此外,对于训练时网络没有接触过的说话者,也能在不重新训练的情况下,仅通过未知...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
【管理系统课程设计】美少女手把手教你后台管理
【文章后台管理系统】URL设计与建模分析+项目源码+运行界面 栏目管理、文章列表、用户管理、角色管理、权限管理模块(文章最后附有源码) 1. 这是一个什么系统? 1.1 学习后台管理系统的原因 随着时代的变迁,现如今各大云服务平台横空出世,市面上有许多如学生信息系统、图书阅读系统、停车场管理系统等的管理系统,而本人家里就有人在用烟草销售系统,直接在网上完成挑选、购买与提交收货点,方便又快捷。 试想,若没有烟草销售系统,本人家人想要购买烟草,还要独自前往药...
4G EPS 第四代移动通信系统
目录 文章目录目录4G 与 LTE/EPCLTE/EPC 的架构E-UTRANE-UTRAN 协议栈eNodeBEPCMMES-GWP-GWHSSLTE/EPC 协议栈概览 4G 与 LTE/EPC 4G,即第四代移动通信系统,提供了 3G 不能满足的无线网络宽带化,主要提供数据(上网)业务。而 LTE(Long Term Evolution,长期演进技术)是电信领域用于手机及数据终端的高速无线通...
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问