- MIME(Multipurpose Internet Mail Extensions) νμ μ μΈν°λ·μμ λ€μν μ’ λ₯μ λ°μ΄ν°λ₯Ό νννκ³ μ μ‘νκΈ° μν νμ€ μλ³μμ΄λ€.
- μλ²κ° ν΄λΌμ΄μΈνΈμκ² μ μ‘λλ λ°μ΄ν°μ μ’ λ₯λ₯Ό λͺ μμ μΌλ‘ μ§μ νμ¬, ν΄λΌμ΄μΈνΈκ° μ¬λ°λ₯΄κ² ν΄μνκ³ νμνλλ‘ λμμ μ€λ€.(HTTP ν€λμ Content-Type)
Primary Type(μ£Ό νμ )/Subtype(λΆ νμ )
νμμΌλ‘ μ΄λ£¨μ΄μ Έ μλ€.
Primary Type
- application
- audio
- font
- example
- image
- message
- model
- multipart
- text
- video
1) application
json
// π’ src/main/java/com/test/lesson01/UrlMappingEx01.java
package com.test.lesson01;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class UrlMappingEx01 extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json"); // βοΈ
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("{\"key1\":\"value1\", \"key2\":\"value2\"}");
}
}
9) text
plain
// π’ src/main/java/com/test/lesson01/UrlMappingEx01.java
package com.test.lesson01;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class UrlMappingEx01 extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/plain"); // βοΈ
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<html><head><title>MIME νμ
</title></head><body>");
out.print("<h1>λ°μ΄ν°λ₯Ό text/htmlλ‘ ν΄μ</h1>");
out.print("</body></html>");
}
}
html
// π’ src/main/java/com/test/lesson01/UrlMappingEx01.java
package com.test.lesson01;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class UrlMappingEx01 extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html"); // βοΈ
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<html><head><title>MIME νμ
</title></head><body>");
out.print("<h1>λ°μ΄ν°λ₯Ό text/htmlλ‘ ν΄μ</h1>");
out.print("</body></html>");
}
}
π https://www.iana.org/assignments/media-types/media-types.xhtml