struts2 action注解纯注解 怎么老是There is no Action mapped for namespace

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(2939)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'Spring security和struts2集成时异常There is no Action mapped for namespace / and action name j_spring_security_logout.',
blogAbstract:'There is no Action mapped for namespace / and action name j_spring_security_logout. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opens',
blogTag:'',
blogUrl:'blog/static/8',
isPublished:1,
istop:false,
modifyTime:3,
publishTime:8,
permalink:'blog/static/8',
commentCount:0,
mainCommentCount:0,
recommendCount:2,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}10101人阅读
STRUTS2(72)
我用最新版本的Struts2.3.4做注解操作的时候,一直出现这个问题。花了近两个小时才解决,错误原因让人啼笑皆非……
TestAction.java
目录结构:
乍一看,是没有任何问题的!可是只要一运行就报错!在百思不得其解后,突然发现我这个包名建的有点特别,问题就出在这里!将Action换成action就可以了,以下是Struts2的原文文档:
&First the Convention plugin finds packages named&struts,&struts2,&action&or&actions.
Any packages that match those names are considered the root packages for the Convention plugin. Next, the plugin looks at all of the classes in those packages as well as sub-packages and determines if the classes implementcom.opensymphony.xwork2.Action&or
if their name ends with&Action&(i.e. FooAction).
注意我标红的内容,也就是说,如果要用Struts2的注解,你还非得将action处理类放在struts,&struts2,&action,&actions包或者其子包中。以前总是习惯性的将所有的action处理类放在com.xxx.action下,以为仅仅是习惯而已,没曾想Struts2还就是这么规定的。
碰到了同样的问题,以前确实不知道基于注解的 struts 配置 需要将action类 放在 名字为 action 的package下。
所用JAR包:
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.5.jar
commons-fileupload-1.2.1.jar
commons-io-1.4.jar
commons-lang-2.3.jar
commons-logging-1.1.1.jar
commons-validator-1.3.1.jar
ezmorph-1.0.4.jar
freemarker-2.3.8.jar
jsf-api.jar
jsf-impl.jar
jstl-1.2.jar
ognl-2.6.11.jar
struts2-convention-plugin-2.2.1.1.jar
struts2-core-2.2.1.1.jar
xml-apis-1.0.b2.jar
xwork-core-2.2.1.1.jar
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:4281880次
积分:41510
积分:41510
排名:第71名
原创:210篇
转载:2237篇
评论:450条
(12)(96)(177)(114)(86)(40)(43)(73)(15)(10)(17)(12)(6)(20)(27)(54)(71)(97)(74)(32)(2)(24)(21)(62)(60)(36)(23)(27)(46)(34)(76)(63)(121)(142)(74)(54)(120)(77)(42)(4)(12)(19)(1)(9)(15)(19)(18)(16)(31)(79)(68)Eclipse中配置Struts2出现There is no Action mapped for action name loginAction. - [unknown l... - 推酷
Eclipse中配置Struts2出现There is no Action mapped for action name loginAction. - [unknown l...
eclipse中配置struts2时报:
& & & & & Eclipse中配置Struts2出现There is no Action mapped for action name loginAction. - [unknown location]
& & & & & 错误
做如下检查:
1、确保struts.xml文件名大小写正确:struts.xml(全部小写,我就是这里出错了)
2、确保struts.xml文件在src目录下(很重要!后面就着重说这个)
& & &web.xml
1 &? xml version= &1.0& encoding= &UTF-8& ?&2 & web-app xmlns:xsi= &http://www.w3.org/2001/XMLSchema-instance& xmlns= &/xml/ns/javaee& xsi:schemaLocation =&/xml/ns/javaee /xml/ns/javaee/web-app_2_5.xsd& id= &WebApp_ID& version = &2.5&&
& display-name &Struts &/display-name &
&filter-name &struts2 &/filter-name &
&filter-class &org.apache.struts2.dispatcher.FilterDispatcher &/filter-class &
&/ filter&
& filter-mapping &
&filter-name &struts2 &/filter-name &
&url-pattern &/* &/url-pattern &
&/ filter-mapping &
& welcome-file-list &
&welcome-file &login.jsp &/welcome-file &
&/ welcome-file-list &
19 &/ web-app&
&struts.xml
1 &?xml version=&1.0& encoding=&UTF-8& ?&
2 &!DOCTYPE struts PUBLIC
&-//Apache Software Foundation//DTD Struts Configuration 2.3//EN&
&http://struts.apache.org/dtds/struts-2.3.dtd&&
5 &struts&
&package name=&default& namespace=&/& extends=&struts-default&&
&action name=&LoginAction& class=&com.lizanhong.action.LoginAction&&
&!-- 定义逻辑视图和物理资源之间的映射 --&
&result name=&error&&index.jsp&/result&
&result &/WEB-INF/main.jsp&/result&
&/package&
13 &/struts&
&%@ page language=&java& contentType=&text/ charset=GB18030&
pageEncoding=&GB18030&%&
&%@ taglib prefix=&s& uri=&/struts-tags& %&
4 &!DOCTYPE html PUBLIC &-//W3C//DTD HTML 4.01 Transitional//EN& &http://www.w3.org/TR/html4/loose.dtd&&
7 &meta http-equiv=&Content-Type& content=&text/ charset=GB18030&&
8 &title&Struts2登录界面&/title&
&s:form action=&LoginAction& namespace=&/&&
13 &td colspan=&2& align=&center&&
&td colspan=&2&&
&s:actionerror /&
&s:fielderror /&
&s:password name=&name& label=&用户名&&&/s:password&
&s:textfield name=&password& label=&密码&&&/s:textfield&
name=&submit&
value=&确定& &&/s:submit&
24 &/s:form&
25 &/body&
26 &/html&
错误总结:
1. & struts.xml中的 &action&标签name=&LoginAction&要与 index.jsp中 &form&标签action=&LoginAction& 一致;
2. &&struts.xml中的 &package&标签namespace=&/&要与 index.jsp中 &form&标签namespace=&/& 一致;
3. & 配置好后若有修改重启一下服务器;
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致there is no action mapped for namespace / and action name解决办法 - solo.du - ITeye技术网站
博客分类:
1.-----首先查看你的struts.xml 文件是否在src目录下;
2.-----检查struts.xml文件的语法是否正确:
如果1正确的话那就一定是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"&
&package name="struts2" extends="struts-default"&
&action name="login" class="com.test.action.LoginAction"&
&result name="success"&/result.jsp&/result&
&/package&
那么就只有是红字的部分写错了 查看你的是否吧struts-default中间的“-”错写成了struts=default;
我的属于第一种。因为刚开始学这两个框架的整合,不知道struts.xml放到什么地方,我放到了WEB-INF下面了,所以找不到,所以应该是放到src下面,即时在src下面建了个conf个目录,放到它里面也能被struts认识(找)到。
浏览 44497
duyunfengsolo
浏览: 702908 次
来自: 广州
视频下载地址:http://download.csdn.net ...
aaaaaaaaaaaaaaa好久不搞struts2了,搞了一下午,搞不出来了,一直都报There is no Action mapped for namespace / and actio - ITeye问答
搞了一下午了,也没找出问题所在啊...
&filter-name&struts2&/filter-name&
&filter-class&org.apache.struts2.dispatcher.FilterDispatcher&/filter-class&
&filter-mapping&
&filter-name&struts2&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
位置没有设置,因此将struts.xml文件放到src目录下
struts.xml
&!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"&
&constant name="struts.i18n.reload" value="true" /&
&package name="FlowerPackage" extends="struts-default"
namespace="/"&
&action name="register" class="com.flower.web.action.RegisterAction"&
&result name="success"&/login.jsp&/result&
&result name="error"&/register.jsp&/result&
&action name="login" class="com.flower.web.action.LoginAction"&
&result name="success"&/login.jsp&/result&
&/package&
jsp文件中提交的表单直接用的 login.action来访问的...
怎么改也改不对了...
我弄了 不会报你的那个错
你的JSP页面的Action是& login.action 吗?
映射路径不对,找不到匹配action,看看namespace是否有误,jsp搞出来我看下就一切都ok啦
你写的应该没有问题的.. 可能是form里面action的值有问题
你直接http://localhost:8080/项目/login.action 试一下好不好用...
引用&filter&
&filter-name&struts2&/filter-name&
&filter-class&org.apache.struts2.dispatcher.FilterDispatcher&/filter-class&
&filter-mapping&
&filter-name&struts2&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
修改成这样就可以了,你这样配置拦截了所有请求,/这样的肯定是没有actin对应的啦
&filter-name&struts2&/filter-name&
&filter-class&org.apache.struts2.dispatcher.FilterDispatcher&/filter-class&
&filter-mapping&
&filter-name&struts2&/filter-name&
&url-pattern&*.action或者其他的&/url-pattern&
&/filter-mapping&[/
把你的JSP贴出来看看塞
已解决问题
未解决问题

我要回帖

更多关于 struts2的namespace 的文章

 

随机推荐