近日碰到奇怪的問題,應該挺好解決的,可是就是卡住我兩天
下面我來描述一下問題
用的是springmvc,自然需要controller,假設我現在所有的配置都是對的。
controller代碼
@RequestMapping(method = RequestMethod.GET)
public String update(Model model) {
System.out.println("service update");
model.addAttribute("greetings", "I came from Model not ModelAttribute");
System.out.println(model.toString());
return "success";
}
成功后的html畫面
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <body> <h2>Add Book</h2> bookname:<input type="text" name="name" id="name" value="${book.name}"> author:<input type="text" name="author" id="author" value="${book.author}"> <p><c:out value="${greetings}" /> </p> <p>${greetings}</p> </body> </html>
最后頁面上始終是${greetings}
奇怪就奇怪在這里,圖上也可以看到了,我用c:out也試過了,就是失敗。
解決方法:
這個解決方法絕對夠簡單,但是就是想不到
原來是<%@ page isELIgnored="false" %>沒有加
如果一定要追查為什么,只能說,默認EL的忽略是true的,所以EL是沒法使用的。
就這么簡單的問題,竟然卡住了我兩天,可見能卡住我們的,才是經驗的積累。
如果什么都很順暢的話,錢也太好賺了不是嗎?