为什么我得到了没有针对命名空间/动作名称loginAction映射的动作?(why am i getting There is no Action mapped for namespace / and action name loginAction?)
我有一个Struts 2 + Hibernate + Spring Eclipse Web应用程序。
它最初构建为使用Tomcat 7.0运行,但是当我尝试将其迁移到WeblLogic 12c时,我得到了异常:“没有映射名称空间/操作名称loginAction的Action。”
奇怪的是,如果我从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注释失败???? 提前致谢。
I got an Struts 2 + Hibernate + Spring Eclipse web application.
It was originally build to run with Tomcat 7.0, but when I try to migrate it to WeblLogic 12c I get the exception:"There is no Action mapped for namespace / and action name loginAction."
The weird thing is that if I launch the application from eclipse to run on Weblogic it works fine, but if I export the war and deploy it manually I get the previous error mentioned. In my struts.xml I have a couple of configuration, but most of the struts configurations are annotations.
Here is my 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>
Here is an excerpt of my login action:
@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(); } }
Does anyone knows why are the struts2 annotations failing???? Thanks in advance.
原文:https://stackoverflow.com/questions/29291889
最满意答案
您正在做的是GET请求类型。
需要将参数传递给初始重写变量。
尝试这个:
RewriteRule ^search/([^/]*)/$ /directory/search.php?&q=$1 [L]
要POST数据,不要GET:
RewriteRule ^search /directory/search.php?q=$1 [NC,P]
“P”的作用类似于“L”,因为它停止处理规则,但它也告诉模块该请求应该完整地传递给代理模块(意味着POST数据被保留)。
此外,请确保打开重写引擎,并设置选项。 如果没有重写引擎,它将给你一个500错误。
这就是我通常使用的:
Options +FollowSymlinks Options -MultiViews RewriteEngine On RewriteBase / ErrorDocument 404 /error.php ErrorDocument 300 /error.php RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
What you are doing is a GET request type.
Need to pass the parameter to the initial rewrite variable.
Try this:
RewriteRule ^search/([^/]*)/$ /directory/search.php?&q=$1 [L]
To POST data, not GET:
RewriteRule ^search /directory/search.php?q=$1 [NC,P]
"P" acts like "L" in that it stops processing rules but it also tells the module that the request should be passed off to the proxy module intact (meaning POST data is preserved).
Also, make sure you turn the rewrite engine on, and set your options. without the rewrite engine on, it will give you a 500 error.
This is what I typically use:
Options +FollowSymlinks Options -MultiViews RewriteEngine On RewriteBase / ErrorDocument 404 /error.php ErrorDocument 300 /error.php RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
相关问答
更多-
您正在寻找的规则是: RewriteRule ^([^/]*)/?$ /full_posts.php?permalink=$1 [L] RewriteRule ^category/([^/]*)/?$ /search.php?category=$1 [L] 在这两种情况下,我都使用了斜线斜线。 你可以测试你的规则: http : //htaccess.madewithlove.be/ The rules you are looking for are: RewriteRule ^([^/]*)/?$ /f ...
-
你有这样的规则: RewriteEngine On RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC] RewriteRule ^ /%1/ [R=302,L,NE] RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] RewriteRule ^(.+?)/?$ /$1.php [L] Have your rule like this: RewriteEngine On RewriteCon ...
-
你可以试试这个吗? ([az-\s]+) RewriteRule ^([0-9]+)$ /html/index.php?phone=$1 [QSA,L] RewriteRule ^([A-Za-z-\s]+)$ /html/index.php?lastname=$1 [QSA,L] RewriteRule ^([A-Za-z-\s]+)/([A-Za-z-\s]+)$ /html/index.php?lastname=$1&name=$2 [QSA,L] Can you try this? ([a-z-\ ...
-
目前,您想知道如何将丑陋的URL(例如/view.php?mode=prod&id=1234 )转换为漂亮的URL(例如/products/product-title )。 从另一个角度开始看这个。 你想要的是有人输入/products/product-title来实际将它们带到可以通过/view.php?mode=prod&id=1234访问的/view.php?mode=prod&id=1234 。 即你的规则可以如下: RewriteRule ^products/([A-Za-z0-9-])/?$ / ...
-
您正在做的是GET请求类型。 需要将参数传递给初始重写变量。 尝试这个: RewriteRule ^search/([^/]*)/$ /directory/search.php?&q=$1 [L] 要POST数据,不要GET: RewriteRule ^search /directory/search.php?q=$1 [NC,P] “P”的作用类似于“L”,因为它停止处理规则,但它也告诉模块该请求应该完整地传递给代理模块(意味着POST数据被保留)。 此外,请确保打开重写引擎,并设置选项。 如果没有重 ...
-
这应该是你的第二条规则 RewriteRule ^people/([^/]+)/([^/]+)/?$ people.php?search=$1&location=$2 [NC,QSA,L] 它将“/ people / foo / bar”重写为“/people.php?search=foo&location=bar” 试试: RewriteRule ^people/([^/]+)/([^/]+)/?$ people.php?search=$1&location=$2 [NC,QSA,L] Rewrite ...
-
使用.htaccess文件修改WordPress搜索结果URL(Modify WordPress search result URL using .htaccess file)[2023-08-27]
我不认为你可以在没有.html或任何其他技巧的情况下实现这一点,因为默认情况下WP会为帖子使用干净的URL,所以你不能搞乱这些功能,但你可以这样做:RewriteEngine On RewriteBase /blog_name/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ([^/]+)\.ht ... -
htaccess如何在url重写后访问/获取搜索参数(htaccess how to access/get search parameters after a url rewrite)[2022-05-11]
使用RewriteRule上的[QSA]标志 RewriteRule ^search?(.*)/$ displayPage.php?page=search&%1 [QSA] 这是文档 修改查询字符串默认情况下,查询字符串不会更改。 但是,您可以在包含查询字符串部分的替换字符串中创建URL。 只需在替换字符串中使用问号,即表示应将以下文本重新注入查询字符串。 如果要删除现有查询字符串,请仅使用问号结束替换字符串。 要组合新旧查询字符串,请使用[QSA]标志。 Use the [QSA] flag on yo ... -
您可以尝试以下链接: 适合初学者的教程 .htaccess文件) http://www.javascriptkit.com/howto/htaccess.shtml URL重写教程 网址重写) http://www.smashingmagazine.com/2011/11/02/introduction-to-url-rewriting/ Apache官方文档) http://httpd.apache.org/docs/current/howto/htaccess.html You can try thes ...
-
您的规则需要一个条件来阻止匹配您的orignal文件和dirs。 尝试: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)$ page.php?id=$1[L] Your rule needs a condition to keep off matching your orignal files and dirs. Try : Rewri ...