ssh web项目出现错误There is no Action mapped for namespace [/] and action name [login] associate解决办法
2017-11-17 23:26
519 查看
在我学习写项目的时候,为了正确规范我们的代码,会把jsp文件放在WEB-INF 下面,一般不会放在
WEB-INF 下面,因为放在 WEB-INF 下面在浏览器直接能够访问,如果我们不想让用户直接访问就会选择放在WEB-INF
下面。
用MyEclipse 运行项目出现错误“There
is no Action mapped for namespace [/] and action name [login] associate”。
解决办法:
1.检查“struts.xml”配置文件字母有没有错误,大小写是否正确。
2.确保struts.xml文件在src目录下(struts.xm位于src下是为了编译后能找到struts配置文件)。
3.检查web项目输出路径。右键web项目选择“properties”
![](https://img-blog.csdn.net/20171117234026270?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTW9ua2V5QnJvdGhlcnM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
4.按照提示步骤检查项目输出路径是否正确。
5.如果上述问题都没有错误,那就检查下“struts.xml”配置文件(标记为红色的要注意,加上最好)。
<?xml
version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="shop" extends="struts-default" namespace="/">
<!-- 配置访问首页的Action -->
<action name="index" class="indexAction">
<result name="indexok">/WEB-INF/jsp/index.jsp</result>
</action>
</package>
</struts>
6.如果都加上之后还是报错误的话。那就要注意下了,我们的是ssh框架整合,struts里面的Action
的 Class是交给了spring来管理。
struts.xml配置文件:
<?xml
version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="shop" extends="struts-default" namespace="/">
<!-- 配置访问首页的Action -->
<action name="index" class="com.hry.index.action">
<result name="indexok">/WEB-INF/jsp/index.jsp</result>
</action>
</package>
</struts>
Spring配置文件:
<!-- 事务管理 -->
<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 开启注解事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- ==============================Action配置========================== -->
<!-- 访问首页的Action -->
<bean id="indexAction" class="com.hry.shop.index.action.IndexAction" scope="prototype">
</bean>
不知道大家有没有发现,我Spring里面配置的是(
scope="prototype"也不能够缺少,看看自己的是否加上去):
<bean
id="indexAction"class="com.hry.shop.index.action.IndexAction" scope="prototype">
而“
struts.xml”里面接收得是:
<action
name="index" class="com.hry.index.action"> 明显两个不一样,一个是Spring里面我们自己定义的“indexAction”,一个却是我们这个Action的路径,这也是造成错误的一个小细节。
基本上也就是这问题了,如果还有其他问题可以联系本人,我们共同探讨。
WEB-INF 下面,因为放在 WEB-INF 下面在浏览器直接能够访问,如果我们不想让用户直接访问就会选择放在WEB-INF
下面。
用MyEclipse 运行项目出现错误“There
is no Action mapped for namespace [/] and action name [login] associate”。
解决办法:
1.检查“struts.xml”配置文件字母有没有错误,大小写是否正确。
2.确保struts.xml文件在src目录下(struts.xm位于src下是为了编译后能找到struts配置文件)。
3.检查web项目输出路径。右键web项目选择“properties”
4.按照提示步骤检查项目输出路径是否正确。
5.如果上述问题都没有错误,那就检查下“struts.xml”配置文件(标记为红色的要注意,加上最好)。
<?xml
version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="shop" extends="struts-default" namespace="/">
<!-- 配置访问首页的Action -->
<action name="index" class="indexAction">
<result name="indexok">/WEB-INF/jsp/index.jsp</result>
</action>
</package>
</struts>
6.如果都加上之后还是报错误的话。那就要注意下了,我们的是ssh框架整合,struts里面的Action
的 Class是交给了spring来管理。
struts.xml配置文件:
<?xml
version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="shop" extends="struts-default" namespace="/">
<!-- 配置访问首页的Action -->
<action name="index" class="com.hry.index.action">
<result name="indexok">/WEB-INF/jsp/index.jsp</result>
</action>
</package>
</struts>
Spring配置文件:
<!-- 事务管理 -->
<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 开启注解事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- ==============================Action配置========================== -->
<!-- 访问首页的Action -->
<bean id="indexAction" class="com.hry.shop.index.action.IndexAction" scope="prototype">
</bean>
不知道大家有没有发现,我Spring里面配置的是(
scope="prototype"也不能够缺少,看看自己的是否加上去):
<bean
id="indexAction"class="com.hry.shop.index.action.IndexAction" scope="prototype">
而“
struts.xml”里面接收得是:
<action
name="index" class="com.hry.index.action"> 明显两个不一样,一个是Spring里面我们自己定义的“indexAction”,一个却是我们这个Action的路径,这也是造成错误的一个小细节。
基本上也就是这问题了,如果还有其他问题可以联系本人,我们共同探讨。
相关文章推荐
- There is no Action mapped for namespace [/] and action name [login] associate解决办法 .
- There is no Action mapped for namespace [/] and action name [login] associate解决办法
- There is no Action mapped for namespace [/] and action name [login] associate解决办法 .
- Struts应用出现的错误及解决方法:There is no Action mapped for namespace / and action name login
- struts2提示“There is no Action mapped for namespace [/] and action name [XXX]... ”错误的解决办法
- 每当使用struts2动态方法调用时,总是出现错误:There is no Action mapped for namespace [/user] and action name [user!add]
- eclipse中配置struts2出现There is no Action mapped for namespace [/] and action name [Login] associated wi
- struts2种出现的There is no Action mapped for namespace [/] and action name 错误
- eclipse中配置struts2出现There is no Action mapped for namespace [/] and action name [Login] associated w
- eclipse中配置struts2出现There is no Action mapped for namespace [/] and action name [Login] associated w
- struts2出现There is no Action mapped for namespace [/] and action name [Login] associated wi
- IDEA配置Struts2出现There is no Action mapped for namespace [/] and action name [login]
- struts 配置出现错误 There is no Action mapped for namespace [/] and action name [findPage] associated with
- eclipse中配置struts2出现There is no Action mapped for namespace [/] and action name [Login] associated wi
- 彻底解决STRUTS2 错误There is no Action mapped for namespace / and action name login
- 使用Struts2动态方法调用时(DMI)出现There is no Action mapped for namespace [/user] and action name [user!add] 问题
- MyEclispe配置struts2出现There is no Action mapped for namespace [/] and action name [user_all]...问题处理
- 解决STRUTS2 错误 There is no Action mapped for namespace / and action name
- 在使用了Maven后出现了There is no Action mapped for namespace [/] and action name [*] associated with context
- There is no Action mapped for namespace / and action name 问题的解决办法