私はあなたの助けが必要です。私の脳はあなたの助けなしで爆発するでしょう!私は春のMVC + JSPでクイズアプリを書いています。Spring MVC + JSPを使用したクイズ(Quastionare)の作成
私が今行ったこと: 1. HashMap +ハードコード正解を作成しました。 2.私は@RequestMapping(value = "/level_one", method = RequestMethod.POST) public String levelOne() { return "levelone"; }
を作成し、それが可能shoul方法: pics
その後、私はちょうど凍結と私は何をすべきかわからないし、どのようにHashMapと@RequestMapingにこのコードを団結するとJSPでコードを書きますそれを表示してクリック可能にするには??? は、コントローラでは私が書きました:
package ua.kiev.prog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/")
public class MyController {
final private String rightAnswerOne = "Dance";
@ModelAttribute("answerList")
public Map answerList() {
Map<String, String> answerList = new HashMap<String, String>();
answerList.put("one", "Sandbox");
answerList.put("two", "Pixel");
answerList.put("three", "Game");
answerList.put("four", "Picture");
return answerList;
}
@RequestMapping(value = "/level_one", method = RequestMethod.POST)
public String levelOne() {
return "levelone";
}
}