社区
Java EE
帖子详情
标题: struts下使用多个配置文件出错的问题!
xloveronline
2005-08-23 10:58:07
我修改了web.xml配置,增加了<init-param>参数,如:
<param-value>/WEB-INF/struts-config-test.xml</param-value>
然后用wsad里的工具自动产生了名为struts-config-test.xml的新的配置文件。
可是当我在新的配置文件里配置新的action时,运行总是抛出无法找到该action的异常。
是不是我什么地方做的不对啊?
...全文
547
15
打赏
收藏
标题: struts下使用多个配置文件出错的问题!
我修改了web.xml配置,增加了参数,如: <param-value>/WEB-INF/struts-config-test.xml</param-value> 然后用wsad里的工具自动产生了名为struts-config-test.xml的新的配置文件。 可是当我在新的配置文件里配置新的action时,运行总是抛出无法找到该action的异常。 是不是我什么地方做的不对啊?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
15 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
bitou
2005-09-02
打赏
举报
回复
配置文件似乎没错,但你的访问地址应为
http://localhost:8080/上下方根/module/test/testtwo.do
HengHuan
2005-09-02
打赏
举报
回复
顶 ^_^
xloveronline
2005-08-31
打赏
举报
回复
晕!不可能的啊,别乱说啊。。。
super_zzw
2005-08-26
打赏
举报
回复
还有先把你的struts-config中的注释去掉试一下, 记得有一次我是注释出问题好像会引起找不到action
super_zzw
2005-08-26
打赏
举报
回复
看你的配置似乎没有什么问题
你去下个struts1.2版本的看看,我在用的是1.2版本的
xloveronline
2005-08-26
打赏
举报
回复
不行啊!下面是我的配置文件,大家看看有错吗:
web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp">
<display-name>testStruts</display-name>
<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/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/module</param-name>
<param-value>WEB-INF/struts-config-module.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/datetime-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-datetime.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/string-1.0.1</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-string.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/utility</taglib-uri>
<taglib-location>/WEB-INF/lib/utility.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/mailer-1.1</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-mailer.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/application-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-application.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/page-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-page.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/request-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-request.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/response-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-response.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/session-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/taglibs-session.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://jakarta.apache.org/taglibs/i18n-1.0</taglib-uri>
<taglib-location>/WEB-INF/lib/i18n.jar</taglib-location>
</taglib>
<taglib>
<taglib-uri>jspsql</taglib-uri>
<taglib-location>/WEB-INF/lib/jspsql.jar</taglib-location>
</taglib>
<resource-ref id="ResourceRef_1122897238909">
<res-ref-name>jdbc/pagination</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>CONTAINER</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
struts-config-module.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- 数据源 -->
<data-sources>
</data-sources>
<!-- 表单 Bean -->
<form-beans>
<form-bean name="testForm" type="com.maxs.test.forms.TestForm">
</form-bean>
</form-beans>
<!-- 全局异常 -->
<global-exceptions>
</global-exceptions>
<!-- 全局转发 -->
<global-forwards>
</global-forwards>
<!-- 操作映射 -->
<action-mappings>
<action path="/test/testtwo" type="com.maxs.test.actions.TestAction" name="testForm" scope="request">
<forward name="result" path="/testtwo/testResponsePage.jsp" redirect="true" contextRelative="true">
</forward>
</action>
</action-mappings>
</struts-config>
jsp如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html:html>
<HEAD>
<%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%>
<META http-equiv="Content-Type" content="text/html; charset=GB18030">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="../theme/Master.css" rel="stylesheet"
type="text/css">
<TITLE></TITLE>
<SCRIPT language="javaScript">
function toSelect(){
with(document.forms[0])
{
submit();
}
}
</SCRIPT>
</HEAD>
<BODY>
<P>test</P>
<html:form action="/test/testtwo">
//此处提示出错:不能在下列模块的上下文中解析目标 /test/testtwo:/
test
</html:form>
<html:button property="submint" styleClass="button" onclick="toSelect()">
查询
</html:button>
</BODY>
</html:html>
dddeee
2005-08-24
打赏
举报
回复
可用分模块的方式,加一个
<init-param>
<param-name>config/test</param-name>
<param-value>/WEB-INF/struts-config-test.xml</param-value>
</init-param>
当然URL上也得加/test啊
这个可以
super_zzw
2005-08-24
打赏
举报
回复
我在用的都好好的, 你怎么就不行啦?
必须以"/"开头
在你的页面上面<html:form action="/two"...就可以了,子模块名struts会自动帮你加上去的。
forward中也一样,不过模块之间的跳转不能直接以/submoudle/function方式来跳转, 如何在模块之间跳转struts文档有说明
super_zzw
2005-08-23
打赏
举报
回复
你的访问URL对不对啊?
bob_thb
2005-08-23
打赏
举报
回复
那还能用什么方法啊,关注!
xloveronline
2005-08-23
打赏
举报
回复
对不起,这种方式我知道,我不想用这种方式!
myth822
2005-08-23
打赏
举报
回复
多个配置文件使用逗号隔开
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-config-test.xml</param-value>
</init-param>
xloveronline
2005-08-23
打赏
举报
回复
是的,我也早试过了……
不行啊!
应该和url没关系啊,
对了,有个很奇怪的现象:
在struts-config-test.xml中配置action的path=“one/two”
在jsp中的写成<form action='one/two'>就提示错误,在上下文中找不到one/two……
而在struts-config-test.xml中配置forward时,输入的jsp也出现同样现象,我检查过路径是正确的……
ses127127
2005-08-23
打赏
举报
回复
楼上的方法好像不行,我试过的
lj82943421
2005-08-23
打赏
举报
回复
可用分模块的方式,加一个
<init-param>
<param-name>config/test</param-name>
<param-value>/WEB-INF/struts-config-test.xml</param-value>
</init-param>
当然URL上也得加/test啊
使用
多个
Struts
配置文件
关于这份教程这份教程向 Java™ Web 开发人员介绍如何将 Apache
Struts
设置为
使用
多个
配置文件
。将学习不同的
Struts
配置文件
的目的和结构,以及
使用
更小文件的合理性。将经历把现有
Struts
应用程序的大型、复杂的
struts
-config.xml 文件分成按功能组织的
多个
配置文件
的步骤。处理的是更小、更具可管理性的部分,可以让
Struts
应用程序更容易管理和重
struts
配置文件
出错
情况
在我们
使用
struts
2的框架的时候,特别的是对于新人而言,就像我,经常会出现
struts
.xml那里自己认为已经配置好了,但是结果总是
出错
的情况,有的时候甚至你找了大半天也找不到原因,这个时候多半是因为粗心导致的
问题
,一般有以下几种情况:1.如果提示的是类似这样的:java.lang.NoClassDefFoundError: IllegalName: pro/bss/action/tes...
Struts
2框架之
配置文件
struts
.mxl理解
摘要:
struts
.xml是
struts
2开源框架的核心
配置文件
,其中包含一些全局的属性,用户请求和响应Action之间的对应关系,以及配置Action中可能用到的参数,以及处理结果的返回页面。还包括各种拦截器的配置等。本文用源代码的角度,来理解
struts
.xml文件的运行机理,及牵涉的各种文件开发项目前灵活运用
struts
源代码各种文件,省去将所有的参数及key值拼写
出错
。 配置strut
Struts
2的
配置文件
及其元素
Struts
2的
配置文件
及其元素
Struts
2
配置文件
当应用被Tomcat加载时,
struts
2的
配置文件
就已经加载初始化了。
Struts
2的
配置文件
比较多,文件之间有着加载的顺序,如下所示。 顺序
配置文件
名 所在位置 说明 1 default.properties
struts
2-core-2.3.15.3.jar\org\apache\
struts
2 不能修改
struts
2的
配置文件
struts
2的
配置文件
类型
struts
2共有4类
配置文件
,
struts
.properties:定义框架自身的全局变量。
struts
-default.xml:定义框架自身
使用
的action映射及result定义。
struts
-plugin.xml:
struts
插件
使用
的
配置文件
,比如当
使用
struts
和spring结合时就需要在web.xml中引用该配置
Java EE
67,543
社区成员
225,859
社区内容
发帖
与我相关
我的任务
Java EE
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
复制链接
扫一扫
分享
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章