异常信息:
exception
Unable to instantiate Action, loginAction, defined for 'loginAction' in namespace '/'loginAction
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.ClassNotFoundException: loginAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157)
com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107)
com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:223)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
导入的jar文件:
[img]http://dl.iteye.com/upload/picture/pic/90617/97d45138-0021-3cbe-a1a1-167ab1e0cc8c.jpg[/img]
[img]http://dl.iteye.com/upload/picture/pic/90615/be54d974-693d-3ac1-b742-f9902c0c6969.jpg[/img]
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
index.jsp
contextConfigLocation
/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml
org.springframework.web.context.ContextLoaderListener
struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
struts2
/*
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
org.hibernate.dialect.MySQLDialect
true
com/gufengxiachen/s2sh/bean/User.hbm.xml
struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
/result.jsp
/index.jsp
</package>
hibernate映射文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
如果担心jar包有冲突的话~最好先启动一下服务器~看看出来什么信息~然后就百度一下就会之后那些包放在一起就会冲突的了~
Unable to instantiate Action, loginAction, defined for 'loginAction' in namespace '/'loginAction
把 改成
试下
楼主要学会分析问题,呵呵
Unable to instantiate Action, loginAction, defined for 'loginAction' in namespace '/'loginAction
java.lang.ClassNotFoundException: loginAction
通过这两行应该可以看出是什么问题了,
虽然记得默认就有,但还是在前显示加上
[code="xml"]
[/code]
试试。
你要一个一个去测试看是否能拿到Dao,service有可能是你的依赖注入出了问题。
Exception提示的是:loginAction没有实例化,也没有找到相应的“loginAction”类
试试一楼的办法
[b]message There is no Action mapped for namespace / and action name login. [/b]是不是报404错误?
是的~没有找到action或者你页面的namespace属性值和struts.xml那个action的namespace没有配对上~如果可以的话把你页面的那个那一小行贴出来~
试试这样子:
struts.xml变成这样
[code="java"]
<action name="login" class="loginAction">
[/code]
index.jsp变成这样:
[code="java"]
[/code]
从这个例子里好好学一下和的配对
一个struts.xml里面可以有多个标签,在标签里面最好定义一下那个namespace属性(针对用户的我们可以定义为/user,针对商品的我们可以定义为/product)
以上都是举例,这样对于url的划分比较好~
其他文件我没有看了~最近我缺分啊~