我刚学struts2,下面报的个错误不小得怎么弄?
第一個是index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="BIG5"%>
......................
  <body>
   <script>location.href='MyJsp.jsp?state=1';</script>
  </body>
</html>跳到MyJsp.jsp<%@ page language="java" import="java.util.*" pageEncoding="BIG5"%>
<%@ taglib prefix = "s" uri = "/struts-tags" %> 
<%
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>a</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>
    <s:set name="abc" value="<%=request.getParameter("state") %>" />
    <s:if test="#abc==1">
     Max's file here
    </s:if>
   
  </body>
</html>
总是报这个错:
org.apache.jasper.JasperException: /MyJsp.jsp(29,4) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)

解决方案 »

  1.   

    <s:set name="abc" value=" <%=request.getParameter("state") %>" /> 
    这个错了,要这样
    <s:set name="abc" value="#parameters.state[0]%>" /> 
      

  2.   

    樓上的可不可以請問下,為什麼要這樣寫?parameters是什麼?
      

  3.   

    又一個問題,為什麼頁面不能用${}了,用了struts2後,用了也會報According to TLD or attribute directive in tag file, attribute value does not accept any expressions 
      

  4.   

    <s:set name="abc" value="#attr.state" /> 
      

  5.   

    你的OGNL表达式用错了,让编译器误认为你使用了其他的表达式...struts2貌似只支持OGNL表达式。