敲了书上的小Demo,关于拦截器,在输入登陆信息后始终跳不到成功页面。
而MyEclipse也发出这样的警告信息:
No configuration found for the specified action: 'login.action' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
二话不说,上代码
<font color="red" style="font-size: 12px">
<s:property value="#session.errorMsg"/>
<s:form action="login.action" method="post" >
<s:textfield name="username" label="用户名" size="20"></s:textfield>
<s:password name="pwd" label="密码" size="20"></s:password>
<s:submit value="登录"></s:submit>
</s:form>
</font>
<package name = "default" extends = "struts-default" namespace = "/">
<interceptors>
<interceptor name="myitp" class="com.liu.actions.LoginInterceptor"></interceptor>
<interceptor name="contentItp" class="com.liu.actions.ContentInterceptor"></interceptor>
</interceptors>
<action name = "login" class = "com.liu.actions.UserAction">
<result name="success">/success.jsp</result>
<result name = "login">/login.jsp</result>
<interceptor-ref name="myitp"></interceptor-ref>
</action>
<action name="content" class="com.liu.actions.ContentAction">
<result>/content_success.jsp</result>
<result name="login">/content_send.jsp</result>
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="contentItp">
<param name="excludeMethods">login</param>
</interceptor-ref>
</action>
</package>
解决方法:试着在form表单加入<s:form action="login.action" method="post" namespace="/">
还是解决不了。我的心碎。