struts2 问题,跪求各位高手帮忙

bebebird 2010-10-24 04:19:17
大家帮我看一下,我配置Struts2时候,启动tomcat就报下面错误
Exception starting filter struts2
Unable to load configuration. - [unknown location]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
。。。。
Caused by: Unable to find a result type for extension [jsp] in location attribute [/product/frontpage/queryproductlist.jsp]. - [unknown location]
at org.apache.struts2.convention.DefaultResultMapBuilder$ResultInfo.determineType(DefaultResultMapBuilder.java:497)
at org.apache.struts2.convention.DefaultResultMapBuilder$ResultInfo.<init>(DefaultResultMapBuilder.java:469)

2010-10-24 16:03:11,468 ERROR org.apache.struts2.dispatcher.Dispatcher:(CommonsLogger.java:27)
- Dispatcher initialization failed
"privDUnable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
。。。。。

我采用的是Convention Plugin
在web.xml配置下是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>3ashop</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.hncu.web.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

在struts2.xml配置是:
<struts>

<!-- 指定Web应用的默认编码集,相当于调用HttpServletRequest的setCharacterEncoding方法 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<!-- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭 -->
<constant name="struts.serve.static.browserCache" value="false" />
<!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开 -->
<constant name="struts.configuration.xml.reload" value="true" />
<!-- 开发模式下使用,这样可以打印出更详细的错误信息 -->
<constant name="struts.devMode" value="true" />
<!-- 默认的视图主题 -->
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.convention.action.suffix" value="Controller" />
<constant name="struts.convention.action.mapAllMatches"
value="true" />
<!-- 即使没有实现Action接口的类映射成Action,默认为false -->
<constant name="struts.convention.action.checkImplementAction"
value="false" />
<!-- 设置默认 -->
<constant name="struts.convention.default.parent.package"
value="rest-default" />

<!--指定结果页面路径。 convention插件会自动在此路径中寻找文件。放到WEB-INF的目的的保护文件资源,只能通过程序内部跳转才能访问,我们的权限拦截器或其他权限处理只要加到action上就可以了 -->
<constant name="struts.convention.result.path"
value="/WEB-INF/page" />

<!-- 把action对象交给spring创建 -->
<constant name="struts.objectFactory" value="spring" />

<package name="default" namespace="/" extends="rest-default">
<global-results>
<result name="message">/share/message.jsp</result>
<result name="directUrl">/share/directUrl.jsp</result>
</global-results>
</package>
。。。。
我不知道是哪里出了错,代码很多,不能全部写出来。
弄了好久,都没解决,无法启动struts2。
跪求各位高手。。。
...全文
391 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
magong 2010-10-24
  • 打赏
  • 举报
回复
Struts2默认的配置文件名是struts.xml,不是struts2.xml。这个文件还好放在src目录下。
如果非要用struts2.xml这个文件名,则需要为filter多配一个参数,如
        <init-param>
<param-name>config</param-name>
<param-value>/struts2.xml</param-value>
</init-param>

Elim-Zhang 2010-10-24
  • 打赏
  • 举报
回复
将struts交给spring管理,那你有没有加那个用于将struts交给spring管理的包呢
wwwtyb 2010-10-24
  • 打赏
  • 举报
回复
Caused by: Unable to find a result type for extension [jsp] in location attribute [/product/frontpage/queryproductlist.jsp]. - [unknown location]
找不到页面/product/frontpage/queryproductlist.jsp
检查是否存在。。。。
随心点儿 2010-10-24
  • 打赏
  • 举报
回复
加载包的问题
lvsh870228 2010-10-24
  • 打赏
  • 举报
回复
启动加载错误还不好判断? ......
xianlf1107 2010-10-24
  • 打赏
  • 举报
回复
Unable to find a result type for extension [jsp] in location attribute [/product/frontpage/queryproductlist.jsp]. - [unknown location]

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧