最近學習有關springmvc的相關知識,按照下面的網址做一個簡單例子:
https://netbeans.org/kb/docs/web/quickstart-webapps-spring_zh_CN.html
但是最後完成運行時達不到效果,
http://localhost:8080/HelloSpring/hello.htm 顯示正常:
和指示比較了一下,只有下面這個地方沒有作對:
注:確認在 "Fix All Imports"(修復所有導入)對話框中選擇了 org.springframework.validation.BindException 和org.springframework.web.servlet.ModelAndView。
添加了這兩個的導入之後報標題上的錯誤:
springmvc: bindException 的single-type-import已定義具有相同簡名的類型
最後查到原來ide自動導入了下面這兩個:
mport java.net.BindException;
import org.springframework.web.portlet.ModelAndView;
這就導致錯誤。
因此刪除這兩個自動導入的包,加上下面這兩個的導入就成功了:
http://localhost:8080/HelloSpring/hello.htm 網頁正常顯示了: