Front-End

Html 만들기

BaekSJ 2023. 6. 28. 18:27

자바를 이용한 HTML 만들기

 

기본적인 구조

<html>
<head>
    <title>제목</title>
</head>
    <body>
        <table>
        	<tr>
            	<td>
                	<a href="링크주소">
                    	<img src=./파일위치/파일명" />
                    </a>
                </td>
            </tr>
        </table>
    </body>
</html>

tr = table row ( 테이블의 줄을 만드는 역할 )

td = table data 테이블 데이터

 

파일의 위치를 정확하게 적어야 원하는 것을 출력할 수 있다.

 

ArrayList 와 HTML, 다중 클래스의 이용

각 클래스 역할
  MainClass(controller) : 전체적인 컨트롤  
  
  NewsClass(Model) : 한 신문사 정보 저장  (1)
  
  DataClass : 모든 신문사들 정보 저장 (2)
  	private void readData(String url){~~~}
  	 1. 파일읽기 : FileReader / BufferedReader(줄단위)
  	 2. 읽은 내용으로 NaverNewsClass 객체 생성하여
  	 3. ArrayList에 추가 : ArrayList<NaverNewsClass> news
  
  MethodClass : HTML 태그 생성  (3)
  public static String createHTML(ArrayList<NaverNewsClass> news){~~~}
  
  HTML tag들 : <table><tr>
  					    <td>
  					      <a href=' '>
  					        <img src=' ' />
  					      </a>
  					    </td>
  					  </tr>
  			   </table>
  		예) String tags="<img src=' ' />";
  					
  PrintClass(View) : HTML 태그 파일로 저장 (4)
  		public static void saveHTML(String url, String tags){~~~}

 

행렬

 

html 에서 행렬로 배치하고자 할 때 예시

 

행열배치
  
  <table>
  for(int n=0; n<2; n++){	//행
  		<tr>
  	  for(int k=0; k<3; k++){		//열
  	  	<td>  </td>
  	  }
  	  </tr>
  }
  </table>
  
  <table>
  		<tr><td>11</td><td>12</td>13</td></tr>
  		<tr><td>11</td><td>12</td>13</td></tr>
  </table>