Java实现两人五子棋游戏(五) 判断是否有一方胜出

 更新时间:2018年03月26日 17:13:54   作者:v_xchen_v  
这篇文章主要为大家详细介绍了Java实现两人五子棋游戏,判断是否有一方胜出,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

之前的两篇文章:Java实现两人五子棋游戏(二) 画出棋盘Java实现两人五子棋游戏(三) 画出棋子Java实现两人五子棋游戏(四) 落子动作的实现,可以点击查看。

前面我们已经画好了棋盘、棋子并且可以自由的落子了,那么接下来要实现的功能是判断是否有五连珠(暂时不考虑行棋方)。

我们采用遍历棋盘已经落子的位置,查看每个落子点,在它的上下,左右,左下右上,左上右下四个方向的任一方向上是否有五个连续的棋子。

第一步,对棋子类进行改造,之前我们的棋子类只有颜色信息和落子状态,现在要新增一个int型的数据,用于记录遍历过程中当前有几个珠子已知连续。

Chessman.java

package xchen.test.simpleGobang; 
 
public class Chessman { 
  private int color;//1-white,0-black 
  private boolean placed = false; 
  int matchCount = 1; 
   
  public Chessman(int color,boolean placed){ 
    this.color=color; 
    this.placed=placed; 
  } 
   
  public boolean getPlaced() { 
    return placed; 
  } 
 
  public void setPlaced(boolean placed) { 
    this.placed = placed; 
  } 
 
  public int getColor() { 
    return color; 
  } 
 
  public void setColor(int color) { 
    this.color = color; 
  } 
} 

第二步,先从一个方向上判断是否有五连珠,这里采用左右方向作为尝试。

添加了一个isWin函数,用遍历整个棋盘上的有效棋子的方式,来进行胜出判断。

DrawChessBoard.java

package xchen.test.simpleGobang; 
 
import java.awt.Graphics; 
import java.awt.Graphics2D; 
import java.awt.RadialGradientPaint; 
import java.awt.Image; 
import java.awt.Toolkit; 
import java.awt.event.MouseEvent; 
import java.awt.event.MouseListener; 
import java.awt.Color; 
import javax.swing.JPanel; 
 
public class DrawChessBoard extends JPanel implements MouseListener{ 
  final static int BLACK=0; 
  final static int WHITE=1; 
  public int chessColor = BLACK; 
  int chessman_width=30; 
   
  public Image boardImg; 
  final private int ROWS = 19; 
  Chessman[][] chessStatus=new Chessman[ROWS+1][ROWS+1];  
   
  public DrawChessBoard() { 
    boardImg = Toolkit.getDefaultToolkit().getImage("res/drawable/chessboard2.png"); 
    if(boardImg == null) 
      System.err.println("png do not exist"); 
     
    addMouseListener(this); 
  }   
  @Override 
  protected void paintComponent(Graphics g) { 
    // TODO Auto-generated method stub 
    super.paintComponent(g); 
     
    int imgWidth = boardImg.getHeight(this); 
    int imgHeight = boardImg.getWidth(this); 
    int FWidth = getWidth(); 
    int FHeight= getHeight(); 
     
    int x=(FWidth-imgWidth)/2; 
    int y=(FHeight-imgHeight)/2; 
     
    int span_x=imgWidth/ROWS; 
    int span_y=imgHeight/ROWS; 
     
    g.drawImage(boardImg, x, y, null); 
     
    //画横线 
    for(int i=0;i<ROWS;i++) 
    { 
      g.drawLine(x, y+i*span_y, FWidth-x,y+i*span_y); 
    } 
    //画竖线 
    for(int i=0;i<ROWS;i++) 
    { 
      g.drawLine(x+i*span_x, y, x+i*span_x,FHeight-y); 
    } 
     
    //画棋子 
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //System.out.println("draw chessman "+i+" "+j); 
          int pos_x=x+i*span_x; 
          int pos_y=y+j*span_y; 
          float radius_b=40; 
          float radius_w=80; 
          float[] fractions = new float[]{0f,1f}; 
          java.awt.Color[] colors_b = new java.awt.Color[]{Color.BLACK,Color.WHITE}; 
          Color[] colors_w = new Color[]{Color.WHITE,Color.BLACK}; 
          RadialGradientPaint paint; 
          if(chessStatus[i][j].getColor()==1) 
          { 
            //System.out.println("draw white chess"); 
            paint = new RadialGradientPaint(pos_x-chessman_width/2f, pos_y-chessman_width/2f, radius_w*2, fractions, colors_w); 
          }else{ 
            //System.out.println("draw black chess"); 
            paint = new RadialGradientPaint(pos_x-chessman_width/2f, pos_y-chessman_width/2f, radius_b*2, fractions, colors_b); 
          } 
          ((Graphics2D)g).setPaint(paint); 
           
          ((Graphics2D)g).fillOval(pos_x-chessman_width/2,pos_y-chessman_width/2,chessman_width,chessman_width); 
        } 
      } 
    } 
  } 
   
  @Override 
  //当用户按下鼠标按钮时发生 
  public void mousePressed(MouseEvent e) { 
    int point_x=e.getX(); 
    int point_y=e.getY(); 
     
    int imgWidth = boardImg.getHeight(this); 
    int imgHeight = boardImg.getWidth(this); 
    int FWidth = getWidth(); 
    int FHeight= getHeight(); 
     
    int x=(FWidth-imgWidth)/2; 
    int y=(FHeight-imgHeight)/2; 
     
    int span_x=imgWidth/ROWS; 
    int span_y=imgHeight/ROWS; 
     
    //System.out.println("press"); 
    int status_x = 0; 
    int status_y = 0; 
    if(point_x>=x && point_x<=x+imgWidth && point_y>=y && point_y <= y+imgHeight) 
    { 
      //System.out.println("合法"); 
      for(int i=0;i<ROWS+1;i++) 
      { 
        if(point_x>=x-chessman_width/2+1+i*span_x) 
        { 
          if(point_x<=x+chessman_width/2-1+i*span_x)//如果是width/2会在中间点出现两个匹配值 
          { 
            //System.out.println("point x "+i+" "+point_x+" "+(x-chessman_width/2+i*span_x)+" "+(x+chessman_width/2+i*span_x)); 
            status_x = i; 
          } 
        } 
      } 
      for(int i=0;i<ROWS+1;i++) 
      { 
        if(point_y>=y-chessman_width/2+1+i*span_y) 
        { 
          if(point_y <= y+chessman_width/2-1+i*span_y) 
          { 
            //System.out.println("point y "+i+" "+point_y+" "+(y-chessman_width/2+1+i*span_y)+" "+(y+chessman_width/2-1+i*span_y)); 
            status_y = i; 
          } 
        } 
      } 
      Chessman chessman = new Chessman(BLACK, true); 
      chessStatus[status_x][status_y]=chessman; 
      repaint(); 
      if(isWin(status_x, status_y, chessStatus)) 
      { 
        System.out.println("WIN!!!!!"); 
      } 
    } 
  } 
  @Override 
  //当用户按下并松开鼠标按钮时发生 
  public void mouseClicked(MouseEvent e) { 
    // TODO Auto-generated method stub 
  } 
  @Override 
  public void mouseReleased(MouseEvent e) { 
    // TODO Auto-generated method stub 
     
  } 
  @Override 
  public void mouseEntered(MouseEvent e) { 
    // TODO Auto-generated method stub 
     
  } 
  @Override 
  public void mouseExited(MouseEvent e) { 
    // TODO Auto-generated method stub  
  } 
   
  boolean isWin(int point_x,int point_y,Chessman[][] cm) 
  { 
    //int matchCount = 1;//记录连珠的数目 
     
    //横向查找 
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //System.out.println("isWin:"+i+" "+j); 
          //向右侧查找 
          for(int n=1;n<=4;n++) 
          { 
            if((i+n>=0)&&(i+n)<=ROWS) 
            { 
              if(chessStatus[i+n][j]!=null&&chessStatus[i+n][j].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" right count++:"+(i+n)+" "+j+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                break; 
              }   
            } 
          } 
          //向左侧查找 
          for(int n=1;n<=4;n++) 
          { 
            if((i-n>=0)&&(i-n)<=ROWS) 
            { 
              if(chessStatus[i-n][j]!=null&&chessStatus[i-n][j].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" "+"left count++:"+(i-n)+" "+j+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                if(chessStatus[i-n][j]!=null) 
                { 
                  chessStatus[i][j].matchCount = 1; 
                } 
                break; 
              } 
            } 
          } 
          chessStatus[i][j].matchCount=1;//refresh count 
        } 
      } 
    } 
    return false; 
     
  } 
} 

第三步,主模块不变,运行测试一下我们的算法是否正确

Main.java

package xchen.test.simpleGobang; 
 
import java.awt.Container; 
import javax.swing.JFrame; 
 
import xchen.test.simpleGobang.DrawChessBoard; 
 
public class Main extends JFrame{ 
  private DrawChessBoard drawChessBoard; 
  public Main() {    
    drawChessBoard = new DrawChessBoard(); 
     
    //Frame标题 
    setTitle("单机五子棋"); 
     
    Container containerPane =getContentPane(); 
    containerPane.add(drawChessBoard);    
  } 
  public static void main(String[] args) { 
    Main m = new Main(); 
    m.setSize(800, 800); 
    m.setVisible(true); 
  } 
} 

第四步,现在我们一个方向上的判断已经做好了,接下来补全其他三个方向上的判断代码

补足DrawChessBoard.java中的isWin()函数

package xchen.test.simpleGobang; 
 
import java.awt.Color; 
import java.awt.Graphics; 
import java.awt.Graphics2D; 
import java.awt.Image; 
import java.awt.RadialGradientPaint; 
import java.awt.Toolkit; 
import java.awt.event.MouseEvent; 
import java.awt.event.MouseListener; 
 
import javax.swing.JPanel; 
 
public class DrawChessBoard extends JPanel implements MouseListener{ 
  final static int BLACK=0; 
  final static int WHITE=1; 
  public int chessColor = BLACK; 
  int chessman_width=30; 
 
  public Image boardImg; 
  final private int ROWS = 19; 
  Chessman[][] chessStatus=new Chessman[ROWS+1][ROWS+1];  
 
  public DrawChessBoard() { 
    boardImg = Toolkit.getDefaultToolkit().getImage("res/drawable/chessboard2.png"); 
    if(boardImg == null) 
      System.err.println("png do not exist"); 
 
    addMouseListener(this); 
  }   
  @Override 
  protected void paintComponent(Graphics g) { 
    // TODO Auto-generated method stub 
    super.paintComponent(g); 
 
    int imgWidth = boardImg.getHeight(this); 
    int imgHeight = boardImg.getWidth(this); 
    int FWidth = getWidth(); 
    int FHeight= getHeight(); 
 
    int x=(FWidth-imgWidth)/2; 
    int y=(FHeight-imgHeight)/2; 
 
    int span_x=imgWidth/ROWS; 
    int span_y=imgHeight/ROWS; 
 
    g.drawImage(boardImg, x, y, null); 
 
    //画横线 
    for(int i=0;i<ROWS;i++) 
    { 
      g.drawLine(x, y+i*span_y, FWidth-x,y+i*span_y); 
    } 
    //画竖线 
    for(int i=0;i<ROWS;i++) 
    { 
      g.drawLine(x+i*span_x, y, x+i*span_x,FHeight-y); 
    } 
 
    //画棋子 
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //System.out.println("draw chessman "+i+" "+j); 
          int pos_x=x+i*span_x; 
          int pos_y=y+j*span_y; 
          float radius_b=40; 
          float radius_w=80; 
          float[] fractions = new float[]{0f,1f}; 
          java.awt.Color[] colors_b = new java.awt.Color[]{Color.BLACK,Color.WHITE}; 
          Color[] colors_w = new Color[]{Color.WHITE,Color.BLACK}; 
          RadialGradientPaint paint; 
          if(chessStatus[i][j].getColor()==1) 
          { 
            //System.out.println("draw white chess"); 
            paint = new RadialGradientPaint(pos_x-chessman_width/2f, pos_y-chessman_width/2f, radius_w*2, fractions, colors_w); 
          }else{ 
            //System.out.println("draw black chess"); 
            paint = new RadialGradientPaint(pos_x-chessman_width/2f, pos_y-chessman_width/2f, radius_b*2, fractions, colors_b); 
          } 
          ((Graphics2D)g).setPaint(paint); 
 
          ((Graphics2D)g).fillOval(pos_x-chessman_width/2,pos_y-chessman_width/2,chessman_width,chessman_width); 
        } 
      } 
    } 
  } 
 
  @Override 
  //当用户按下鼠标按钮时发生 
  public void mousePressed(MouseEvent e) { 
    int point_x=e.getX(); 
    int point_y=e.getY(); 
 
    int imgWidth = boardImg.getHeight(this); 
    int imgHeight = boardImg.getWidth(this); 
    int FWidth = getWidth(); 
    int FHeight= getHeight(); 
 
    int x=(FWidth-imgWidth)/2; 
    int y=(FHeight-imgHeight)/2; 
 
    int span_x=imgWidth/ROWS; 
    int span_y=imgHeight/ROWS; 
 
    //System.out.println("press"); 
    int status_x = 0; 
    int status_y = 0; 
    if(point_x>=x && point_x<=x+imgWidth && point_y>=y && point_y <= y+imgHeight) 
    { 
      //System.out.println("合法"); 
      for(int i=0;i<ROWS+1;i++) 
      { 
        if(point_x>=x-chessman_width/2+1+i*span_x) 
        { 
          if(point_x<=x+chessman_width/2-1+i*span_x)//如果是width/2会在中间点出现两个匹配值 
          { 
            //System.out.println("point x "+i+" "+point_x+" "+(x-chessman_width/2+i*span_x)+" "+(x+chessman_width/2+i*span_x)); 
            status_x = i; 
          } 
        } 
      } 
      for(int i=0;i<ROWS+1;i++) 
      { 
        if(point_y>=y-chessman_width/2+1+i*span_y) 
        { 
          if(point_y <= y+chessman_width/2-1+i*span_y) 
          { 
            //System.out.println("point y "+i+" "+point_y+" "+(y-chessman_width/2+1+i*span_y)+" "+(y+chessman_width/2-1+i*span_y)); 
            status_y = i; 
          } 
        } 
      } 
      Chessman chessman = new Chessman(BLACK, true); 
      chessStatus[status_x][status_y]=chessman; 
      repaint(); 
      if(isWin(status_x, status_y, chessStatus)) 
      { 
        System.out.println("WIN!!!!!"); 
      } 
    } 
  } 
  @Override 
  //当用户按下并松开鼠标按钮时发生 
  public void mouseClicked(MouseEvent e) { 
    // TODO Auto-generated method stub 
  } 
  @Override 
  public void mouseReleased(MouseEvent e) { 
    // TODO Auto-generated method stub 
 
  } 
  @Override 
  public void mouseEntered(MouseEvent e) { 
    // TODO Auto-generated method stub 
 
  } 
  @Override 
  public void mouseExited(MouseEvent e) { 
    // TODO Auto-generated method stub  
  } 
 
  boolean isWin(int point_x,int point_y,Chessman[][] cm) 
  {   
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        //横向查找 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //向右侧查找 
          for(int n=1;n<=4;n++) 
          { 
            if((i+n>=0)&&(i+n)<=ROWS) 
            { 
              if(chessStatus[i+n][j]!=null&&chessStatus[i+n][j].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" right count++:"+(i+n)+" "+j+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                break; 
              }   
            } 
          } 
          //向左侧查找 
          for(int n=1;n<=4;n++) 
          { 
            if((i-n>=0)&&(i-n)<=ROWS) 
            { 
              if(chessStatus[i-n][j]!=null&&chessStatus[i-n][j].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" "+"left count++:"+(i-n)+" "+j+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                if(chessStatus[i-n][j]!=null) 
                { 
                  chessStatus[i][j].matchCount = 1; 
                } 
                break; 
              } 
            } 
          } 
          chessStatus[i][j].matchCount=1;//refresh count 
        } 
      } 
    } 
 
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        //纵向 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //向下查找,左上角为坐标原点,y轴正方向向下 
          for(int n=1;n<=4;n++) 
          { 
            if((j+n>=0)&&(j+n)<=ROWS) 
            { 
              if(chessStatus[i][j+n]!=null&&chessStatus[i][j+n].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" up count++:"+(i)+" "+(j+n)+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                break; 
              }   
            } 
          } 
          //向上查找 
          for(int n=1;n<=4;n++) 
          { 
            if((j-n>=0)&&(j-n)<=ROWS) 
            { 
              if(chessStatus[i][j-n]!=null&&chessStatus[i][j-n].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" "+"left count++:"+(i)+" "+(j-n)+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                if(chessStatus[i][j-n]!=null) 
                { 
                  chessStatus[i][j].matchCount = 1; 
                } 
                break; 
              } 
            } 
          } 
          chessStatus[i][j].matchCount=1;//refresh count 
        } 
      } 
    } 
 
    //方向:左上右下 
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        //左上 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //向下查找,左上角为坐标原点,y轴正方向向下 
          for(int n=1;n<=4;n++) 
          { 
            if((j-n>=0)&&(j-n)<=ROWS&&(i-n)>=0&&(i-n)<=ROWS) 
            { 
              if(chessStatus[i-n][j-n]!=null&&chessStatus[i-n][j-n].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" up count++:"+(i-n)+" "+(j-n)+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                break; 
              }   
            } 
          } 
          //右下 
          for(int n=1;n<=4;n++) 
          { 
            if((j+n>=0)&&(j+n)<=ROWS&&(i+n)>=0&&(i+n)<=ROWS) 
            { 
              if(chessStatus[i+n][j+n]!=null&&chessStatus[i+n][j+n].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" "+"left count++:"+(i+n)+" "+(j+n)+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                if(chessStatus[i+n][j+n]!=null) 
                { 
                  chessStatus[i][j].matchCount = 1; 
                } 
                break; 
              } 
            } 
          } 
          chessStatus[i][j].matchCount=1;//refresh count 
        } 
      } 
    } 
 
    //方向:左下右上 
    for(int i=0;i<ROWS+1;i++) 
    { 
      for(int j=0;j<ROWS+1;j++) 
      { 
        //左下 
        if(chessStatus[i][j]!=null&&chessStatus[i][j].getPlaced()==true) 
        { 
          //向下查找,左上角为坐标原点,y轴正方向向下 
          for(int n=1;n<=4;n++) 
          { 
            if((j+n>=0)&&(j+n)<=ROWS&&(i-n)>=0&&(i-n)<=ROWS) 
            { 
              if(chessStatus[i-n][j+n]!=null&&chessStatus[i-n][j+n].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" up count++:"+(i-n)+" "+(j+n)+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                break; 
              }   
            } 
          } 
          //右上 
          for(int n=1;n<=4;n++) 
          { 
            if((j-n>=0)&&(j-n)<=ROWS&&(i+n)>=0&&(i+n)<=ROWS) 
            { 
              if(chessStatus[i+n][j-n]!=null&&chessStatus[i+n][j-n].getPlaced()==true) 
              { 
                chessStatus[i][j].matchCount++; 
                System.out.println("pos:"+i+" "+j+" "+"left count++:"+(i+n)+" "+(j-n)+" count:"+chessStatus[i][j].matchCount); 
                if(chessStatus[i][j].matchCount==5) 
                { 
                  return true; 
                } 
              }else 
              { 
                if(chessStatus[i+n][j-n]!=null) 
                { 
                  chessStatus[i][j].matchCount = 1; 
                } 
                break; 
              } 
            } 
          } 
          chessStatus[i][j].matchCount=1;//refresh count 
        } 
      } 
    }     
 
    return false;   
  } 
} 

再运行一下


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • springboot集成redis lettuce

    springboot集成redis lettuce

    目前java操作redis的客户端有jedis跟Lettuce。本文主要介绍了springboot集成redis lettuce,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-09-09
  • Spring Boot 直接用jar运行项目的方法

    Spring Boot 直接用jar运行项目的方法

    这篇文章主要介绍了Spring Boot 直接用jar运行项目的方法,非常不错,具有参考借鉴价值,需要的朋友参考下
    2018-02-02
  • Java字符编码解码的实现详解

    Java字符编码解码的实现详解

    本篇文章介绍了,Java字符编码解码的实现详解。需要的朋友参考下
    2013-05-05
  • springboot实现拦截器的3种方式及异步执行的思考

    springboot实现拦截器的3种方式及异步执行的思考

    实际项目中,我们经常需要输出请求参数,响应结果,方法耗时,统一的权限校验等。本文首先为大家介绍 HTTP 请求中三种常见的拦截实现,并且比较一下其中的差异。感兴趣的可以了解一下
    2021-07-07
  • Spring Boot文件上传原理与实现详解

    Spring Boot文件上传原理与实现详解

    这篇文章主要介绍了Spring Boot 文件上传原理与实现详解,前端文件上传是面向多用户的,多用户之间可能存在上传同一个名称、类型的文件;为了避免文件冲突导致的覆盖问题这些应该在后台进行解决,需要的朋友可以参考下
    2024-01-01
  • SpringMVC的详细架构你了解嘛

    SpringMVC的详细架构你了解嘛

    这篇文章主要为大家介绍了SpringMVC的详细架构,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助
    2022-01-01
  • 浅谈spring和spring MVC的区别与关系

    浅谈spring和spring MVC的区别与关系

    下面小编就为大家带来一篇浅谈spring和spring MVC的区别与关系。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-04-04
  • Spring中的接口重试机制解析

    Spring中的接口重试机制解析

    这篇文章主要介绍了Spring中的接口重试机制解析,大家在做项目的时候,往往会遇到一些接口由于网络抖动等问题导致接口响应超时等,这时候我们会希望能够按照一定的规则进行接口请求重试,需要的朋友可以参考下
    2024-01-01
  • Java避免UTF-8的csv文件打开中文出现乱码的方法

    Java避免UTF-8的csv文件打开中文出现乱码的方法

    这篇文章主要介绍了Java避免UTF-8的csv文件打开中文出现乱码的方法,结合实例形式分析了java操作csv文件时使用utf-16le编码与utf8编码相关操作技巧,需要的朋友可以参考下
    2019-07-07
  • Java/Web调用Hadoop进行MapReduce示例代码

    Java/Web调用Hadoop进行MapReduce示例代码

    本篇文章主要介绍了Java/Web调用Hadoop进行MapReduce示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-11-11

最新评论