1. img 파일 경로
package com.fastcampus.ch2;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller // ctrl+shift+o는 자동 import
public class TwoDice {
@RequestMapping("/rollDice")
public void main(HttpServletResponse response) throws IOException{
int idx1 = (int)(Math.random()*6+1);
int idx2 = (int)(Math.random()*6+1);
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("</head>");
out.println("<body>");
out.println("<img src='resources/img/dice"+idx1+".jpg'>");
out.println("<img src='resources/img/dice"+idx2+".jpg'>");
out.println("</body>");
out.println("</html>");
}
}
- 결과
- 리소스
- 동적 리소스 : 리소스 내용이 고정되어있지 않은 것(프로그램, 스트리밍)
- 정적 리소스 : 파일 형태로 바뀌지 않는것(이미지, *.js, *.css, *.html 등)
- 클라이언트(client) : 서비스를 요청하는 애플리케이션
- 서버(server) : 서비스를 제공하는 애플리케이션
'Spring' 카테고리의 다른 글
8. 설정 파일 server.xml, web.xml - 패스트캠퍼스 백엔드 부트캠프 3기 (0) | 2025.01.31 |
---|---|
7. 클라이언트와 서버 - 패스트캠퍼스 백엔드 부트캠프 3기 (0) | 2025.01.31 |
5. HTTP 요청과 응답 - 패스트캠퍼스 백엔드 부트캠프 3기 (0) | 2025.01.31 |
4. AWS에 배포하기 - 패스트캠퍼스 백엔드 부트캠프 3기 (0) | 2025.01.31 |
3. 원격 프로그램의 실행 - 패스트캠퍼스 백엔드 부트캠프 3기 (2) | 2025.01.31 |