当前位置:编程学习 > 网站相关 >>

websphere 6.1 + struts2

在页面中使用strut2 标签报错,比如<s:property value="sdfsaf" />。这是怎么回事??

而且对于strut2 的请求action,websphere 也说是找不到

为什么???


index.jsp

Java code<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
    This is my JSP page. aaaasdsadsggsd12222222ds31111<br>
    <a href="admin/show!login">登录</a>
    <s:property value="safsaf"/>
  </body>
</html>


struts.xml

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

<struts>

    <!-- 整合Spring -->

    <constant name="struts.objectFactory" value="spring" />

    <constant name="struts.devMode" value="true" />

    <package name="admin" namespace="/admin" extends="struts-default">
        <action name="show" class="com.joyintech.actions.ShowAction">
            <result name="go">/WEB-INF/pages/stock.jsp</result>
        </action>
    </package>    

</struts>


web.xml

Java code    <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.joyin.actions</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>



这个列子在tomcat上运行问题。在webshpere上有报错。

index.jsp上有到struts2的标签报错
抛出的异常:The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

把那个标签删除则正常,但提交请求时,报错说找不到action。 --------------------编程问答-------------------- struts的jar包加了吗 --------------------编程问答-------------------- 加了,在tomcat里能运行


现在就是struts2 的标签用不了 --------------------编程问答-------------------- 正在学习中啊 --------------------编程问答-------------------- 解决方案:
1. 下载并安装补丁:
补丁分两部分:
a. Pak部分
Windows平台系统:
ftp://ftp.software.ibm.com/software/websphere/appserv/support/fixpacks/was61/cumulative/cf61017/WinX32/6.1.0-WS-WAS-WinX32-FP0000017.pak
Linux 其它平台:
ftp://ftp.software.ibm.com/software/websphere/appserv/support/fixpacks/was61/cumulative/cf61017
选择系统型号下载具体的版本。
b. installer部分
Windows系统:
ftp://ftp.software.ibm.com/software/websphere/appserv/support/tools/UpdateInstaller/6.1.x/WinIA32/download.updii.61017.windows.ia32.zip
Linux及其它平台:
ftp://ftp.software.ibm.com/software/websphere/appserv/support/tools/UpdateInstaller/6.1.x
选择系统型号下载具体的版本。

说明:下载两个文件后,先把installer作为一个独立的应用程序安装,然后运行update installer选择webspere server路径及a部分下载的pak包给webspere系统打补丁。
注1:在installer安装完成后,update installer实际上是一个带有向导的应用程序,按向导安装补丁即可
注2:在windows系统上安装比较简单,按上面操作执行即可,在linux系统下,要核对webspere是32位还是64位(注意:这个地方很重要,是日照项目组N次失败经验得来的宝贵经验),根据它下载具体的版本。
2. 设置属性
在服务器->server1->Web 容器设置->Web 容器->定制属性下添加com.ibm.ws.webcontainer.invokefilterscompatibility=true
3. 重启webspere server即可。
--------------------编程问答-------------------- 要打补丁  在tomcat下面是可以的  但是在was服务器下就不行了 比如日期控件不显示什么的...
struts2-plexus-plugin-2.0.11.2_j4.jar --------------------编程问答-------------------- 路过 学习了 --------------------编程问答-------------------- 楼主可试下:
应用程序服务器 > server01 > Web 容器 > 定制属性
新建一个属性:
名称:com.ibm.ws.webcontainer.invokefilterscompatibility  
值为:true     --------------------编程问答-------------------- 另外楼主记得重新启动一下 server01(你自己的server名) --------------------编程问答-------------------- 我以前也遇到过,那是因为该版本的was需要一下设置,即 jack914 的方式,才可以运行struts2 --------------------编程问答-------------------- 这个是因为struts2存在bug,你用高版本的就行了,比如就2.1的就解决了这类问题 --------------------编程问答--------------------
我也遇到这个问题,大大们教教如何解决
使用框架:
Struts2.1.8
Spring3.0
Hibernate3.3
环境平台:
windows2003
websphere6.1.0.31
报错404 Not Found --------------------编程问答--------------------
引用 7 楼 jack914 的回复:
楼主可试下:
应用程序服务器 > server01 > Web 容器 > 定制属性
新建一个属性:
名称:com.ibm.ws.webcontainer.invokefilterscompatibility  
值为:true

这个试过了,没效果
引用 9 楼 chowgofee 的回复:
我以前也遇到过,那是因为该版本的was需要一下设置,即 jack914 的方式,才可以运行struts2

你是怎么弄的? --------------------编程问答-------------------- 学习学习~~~~
补充:企业软件 ,  WebSphere
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,