最近开始学习struts2,于是搭建了个简单登陆页面试试。
环境:MyEclipse8.5 + tomcat6.0
struts2版本:2.1.8.1
问题1:
ERROR - Dispatcher initialization failed
struts2 -- Unable to load configuration - bean - jar:file: struts-default.xml
解决方法:把commons-fileupload-1.2.1.jar加进来就可以了。
问题2:
警告: Could not find action or result
There is no Action mapped for namespace / and action name . - [unknown location]
如果系统能够正确运行,说明配置没问题。当有这个警告时:
解决办法:因为在MyEclipse中创建项目时,产生了一个默认的index.jsp页面,一般将它删除重新创建一个页面,比如login.jsp,但在web.xml中的<welcome-file>中依然写的是index.jsp,所以当运行时,系统默认找的是index.jsp页面,因为此页面已经删除,所以给出一个警告,但不影响系统运行。
所以,只要修改成 如<welcome-file>login.jsp</welcome-file>就可以了。或者删除掉welcome-file,但在浏览器中要输入完整的URL,包含诸如login.jsp之类的。
如果不是这个原因,那就要检查action的名称、struts.xml的配置及其存放位置等是否正确。
环境:MyEclipse8.5 + tomcat6.0
struts2版本:2.1.8.1
问题1:
ERROR - Dispatcher initialization failed
struts2 -- Unable to load configuration - bean - jar:file: struts-default.xml
解决方法:把commons-fileupload-1.2.1.jar加进来就可以了。
问题2:
警告: Could not find action or result
There is no Action mapped for namespace / and action name . - [unknown location]
如果系统能够正确运行,说明配置没问题。当有这个警告时:
解决办法:因为在MyEclipse中创建项目时,产生了一个默认的index.jsp页面,一般将它删除重新创建一个页面,比如login.jsp,但在web.xml中的<welcome-file>中依然写的是index.jsp,所以当运行时,系统默认找的是index.jsp页面,因为此页面已经删除,所以给出一个警告,但不影响系统运行。
所以,只要修改成 如<welcome-file>login.jsp</welcome-file>就可以了。或者删除掉welcome-file,但在浏览器中要输入完整的URL,包含诸如login.jsp之类的。
如果不是这个原因,那就要检查action的名称、struts.xml的配置及其存放位置等是否正确。