我有一个Struts 2 + Hibernate + Spring Eclipse Web应用程序。
它最初构建为使用Tomcat 7.0运行,但是当我尝试将其迁移到WeblLogic 12c时,我得到异常:“没有映射名称空间/动作名称loginAction的动作。”
奇怪的是,如果我从eclipse启动应用程序以在Weblogic上运行它可以正常工作,但如果我导出战争并手动部署它,我会得到之前提到的错误。 在我的struts.xml中,我有几个配置,但大多数struts配置都是注释。
这是我的struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apa che.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.action.excludePattern" value="/rest/.*?" />
<constant name="struts.devMode" value="false" />
<constant name="struts.multipart.maxSize" value="104857600" />
<package name="mi-paquete" extends="struts-default">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="LoginInterceptor"
class="com.proximate.www.pushmate.interceptors.LoginInterceptor" />
<interceptor-stack name="loginStack">
<interceptor-ref name="LoginInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loginStack" />
<global-results>
<result name="loginAction">/jsp/template/loginLayout.jsp</result>
<result name="errorAction">/jsp/error/error.jsp</result>
</global-results>
<action name="olvidoContrasenia"
class="com.proximate.www.pushmate.action.OlvidoContraseniaAction">
<result name="formResult">/jsp/template/olvidoContrasenaLayout.jsp</result>
</action>
</package>
</struts>
以下是我的登录操作的摘录:
@ParentPackage("mi-paquete")
@Action(value="loginAction")
@InterceptorRefs({
@InterceptorRef(value="defaultStack", params = {"excludeMethods","validaUsuario"})
})
@Results({
@Result(name="success", location="/jsp/template/loginLayout.jsp"),
@Result(name=ActionsConstants.ERROR, type="tiles", location=ActionsConstants.URL_ERROR),
@Result(name = "welcome", type = "redirectAction", location = "welcomeAction.action"),
@Result(name = "registroUsuario", location = "/jsp/template/concluyeRegistroLayout.jsp"),
})
public class LoginAction extends ActionSupport implements SessionAware, ServletRequestAware {
/**
*
*/
private static final long serialVersionUID = 1218879876500264583L;
private static final Logger logger = Logger.getLogger(LoginAction.class.getName());
private Login loginObj;
private static String URLAplication = null;
private static String URLReportes = null;
@Autowired
private IUsuarioService usuarioService;
@Autowired
private IMenuDAO menuUsuarioDAO;
@Autowired
private ILogDAO logDAO;
Map<String, Object> session;
HttpServletRequest request;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return validaUsuario();
}
}
有谁知道为什么struts2注释失败? 提前谢谢。
答案 0 :(得分:0)
我认为你需要指定命名空间。你有没有尝试过:
@Action(value="/loginAction")
答案 1 :(得分:0)
我在struts.xml中添加了下两行来解决问题:
<constant name="struts.convention.action.includeJars" value=".*?\.jar(!/|/)?" />
<constant name="struts.convention.action.fileProtocols" value="jar,zip" />