个人猜想你的Lookup中不是这么写的:dataSourceA=getDataSource(request,"A");最好能贴个代码看看

解决方案 »

  1.   

    补充一下。
    在struts中添加数据源的做法是很不好的,违反了MVC的原则,应该在 App server中设置数据源的JNDI
    这个tag即将在struts 2.x中被摈弃。
      

  2.   

    那就是数据源配置的问题,或者是数据库连接的问题。数据源配错了,或者根据配置不能连接到数据库,tomcat启动时会出错。
    程序也会跑不起来。我们项目中也出现过这个问题。
      

  3.   

    在我的代码中没有使用对数据库进行相应的操作(本来是想从数据查询数据的,但现在出错了,我都注释掉了代码),在没有添加<data-sources>...</data-sources>时是正确的,现在只要添加上这里的相关的代码部分(去掉上面所写的注释部分)就会出现所例示的错误信息,启动Tomcat时控制台上没有出现错误信息!
    如下是相关的源代码:
    public class LookupAction
        extends Action {
      public LookupAction() {
      }  protected Double getQuote(String symbol,HttpServletRequest request) {
        if (symbol.equalsIgnoreCase("SUNW")) {
          return new Double(25.00);
        }
        return null;
      }  public ActionForward execute(ActionMapping mapping, ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response) throws IOException,
          ServletException {
        Double price = null;
        String target = new String("success");
        String symbol = null ;    if (form != null) {
          LookupForm lookupForm = (LookupForm) form;
          symbol = lookupForm.getSymbol();
          price = getQuote(symbol,request);
        }
        if (price == null) {
          ActionErrors errors = new ActionErrors();
          errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("errors.lookup.symbol.required",symbol));
          if (!errors.isEmpty()){
            saveErrors(request, errors);
          }
        }
        else {
          request.setAttribute("PRICE", price);
        }
        return (mapping.findForward(target)) ;
      }
    }JSP:
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page language="java"%>
    <%@ taglib uri="/struts-html.tld" prefix="html"%>
    <%@ taglib uri="/struts-bean.tld" prefix="bean"%>
    <html>
    <head>
    <title>Wiley Struts Test</title>
    </head>
    <body>
      <html:errors/>
      <html:form action="Lookup" name="lookupForm" type="wiley.LookupForm">
        <table width="%45" border="0">
          <tr>
            <td><bean:message key="app.symbol" />:</td>
            <td>Symbol:</td>
            <td><html:text property="symbol"></html:text></td>
          </tr>
          <tr>
            <td colspan="3" align="center"><html:submit></html:submit></td>
          </tr>
        </table>
      </html:form>
    </body>
    </html>
      

  4.   

    <set-property property="user" value="sa"/> 更改为 <set-property property="username" value="sa"/> 然后添加struts-legacy.jar 到lib下,就运行正常了,谢谢大家