最近学习有关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 网页正常显示了: