在页面中使用strut2 标签报错,比如<s:property value="sdfsaf" />。这是怎么回事??而且对于strut2 的请求action,websphere 也说是找不到为什么???

解决方案 »

  1.   

    在问为什么之前
    麻烦你贴出你相关的代码
    还有上下文背景你问的东西跟你写的代码有关
    你知道代码
    你可以问
    可是我们不知道你的代码!!!你的那个标签是否在使用的页面进行引用了????
    你修改struts.xml的之后是否重启服务器????
      

  2.   

    好的!index.jsp<%@ 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<?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 <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。
      

  3.   

    你把tag放到web.xml里面注册一下  <taglib>
        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      

  4.   

    那个action请求,是怎么回事??是不是因为WebSphere 的一些filter把这个请求给拦截了???
      

  5.   

    没看到你spring的配置文件,web.xml文件应该:   <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
           
    <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:applicationContext*.xml</param-value> 
    </context-param>

    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>  
    </filter> <filter-mapping> 
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
      

  6.   

    如果你用spring的话,你struts.xml文件也有问题。ShowAction.java也应该贴出来看看。
      

  7.   

    现在websphere与strut 、spring的整合酶问题了
    就是在jsp页面上用struts2标签时,还是用不了
      

  8.   

    你用的是struts2.0.x吧,这个版本有不少bug