首页 > 其他分享 >ERROR [org.apache.struts.action.RequestProcessor] - Invalid path /xxxx was requested

ERROR [org.apache.struts.action.RequestProcessor] - Invalid path /xxxx was requested

时间:2022-12-02 22:37:56浏览次数:49  
标签:xml RequestProcessor www xxxx requested http qdgl org config


Struts Prblems:

  • ​​1. Invalid path /qdgl was requested​​
  • ​​2. 添加sqlMap配置文件​​

1. Invalid path /qdgl was requested

js中页面跳转请求的url为:​​window.location.href="${pageContext.request.contextPath}/qdgl/qdgl.do?method=toGmrk";​

Action里面也添加了toGmrk方法:

public ActionForward toGmrk(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) {
System.out.println("=======toGmrk==========");
UserSessionBean userSessionBean = UserSessionUtils.getCurrentSessionUser(request.getSession());
String roleid = userSessionBean.getRoleID();
request.setAttribute("roleid", roleid);
return mapping.findForward("gmrk");
}

applicationContext-qdgl.xml里面也添加了映射,但是不确定对不对

<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="daoUtilsAddons" class="com.jadlsoft.utils.DaoUtilsAddons" parent="baseManager" />
<bean id="qdglManager" class="com.jadlsoft.business.admin.QdglManager" scope="singleton" parent="baseManager" />

<bean name="/qdgl/qdgl" class="com.jadlsoft.struts.action.qdgl.QdglAction" scope="singleton">
<property name="qdglManager">
<ref local="qdglManager"/>
</property>
</bean>

</beans>

struts-config-qdgl.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources />
<form-beans>
<form-bean name="qdglForm" type="com.xxxx.struts.form.rygl.RyglForm"></form-bean>
</form-beans>
<global-exceptions />
<global-forwards></global-forwards>

<action-mappings>
<action path="/qdgl" parameter="method" scope="request" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="save_gmrk" path="/../qdgl/save_gmrk.jsp" />
</action>
</action-mappings>

</struts-config>

查了半天一直没有检查​​web.xml​​​ 文件, 添加了Struts的配置文件后,也需要在这个​​web.xml​​​里面配置​​struts-config-xxx.xml​​的。

在 ​​<servlet>​​​ 标签中添加 ​​<init-param>​

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config/struts-config.xml</param-value>
</init-param>

<init-param>
<param-name>config/qdgl</param-name>
<param-value>
/WEB-INF/config/struts-config-qdgl.xml
</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

到这里,页面跳转的功能实现了,不再是404了。

另外还有一点,​​struts-config-qdgl.xml​​​ 里面的action 标签的path属性的值,需要是请求的URL的最后的模块名,我这里是不用带​​.do​​​,这点应该同ssm框架里面一样,在配置文件里面配置过后,就不用带​​.do​​去配置了。

2. 添加sqlMap配置文件

需要在 ​​applicationContext.xml​​ 的sqlLocate中添加 配置文件名称

<property name="sqlLocate" value="sqlmapconfig-bwgl.xml,sqlmapconfig-rcgl.xml" />


标签:xml,RequestProcessor,www,xxxx,requested,http,qdgl,org,config
From: https://blog.51cto.com/linmengmeng/5907643

相关文章