MCPcopy Create free account
hub / github.com/castello/spring_basic / TwoDice

Class TwoDice

ch2/TwoDice.java:10–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8import java.io.PrintWriter;
9
10@Controller
11public class TwoDice {
12 @RequestMapping("/rollDice")
13 // public static void main(String[] args) {
14 public void main(HttpServletResponse response) throws IOException {
15 int idx1 = (int)(Math.random()*6)+1;
16 int idx2 = (int)(Math.random()*6)+1;
17
18 response.setContentType("text/html");
19 response.setCharacterEncoding("utf-8");
20 PrintWriter out = response.getWriter();
21 out.println("<html>");
22 out.println("<head>");
23 out.println("</head>");
24 out.println("<body>");
25 out.println("<img src='resources/img/dice"+idx1+".jpg'>");
26 out.println("<img src='resources/img/dice"+idx2+".jpg'>");
27 out.println("</body>");
28 out.println("</html>");
29 out.close();
30 }
31}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected