个人猜想你的Lookup中不是这么写的:dataSourceA=getDataSource(request,"A");最好能贴个代码看看
解决方案 »
- 有高手帮我看下嘛? lucene的问题
- spring与action整合 NullPointerException
- java怎么post一个https的请求?
- 调查 大公司都用什么J2EE 服务器呢??
- ResultSet对象怎么从后台传到jsp上的
- 时间计算的问题,请赐教
- 如何解决tomcat与oracle apache http server冲突问题
- Source not found for NativeMethodAccessorImpl.invoke(Object, Object[]) line: no
- Hadoop系统实际运行的时候是不是都是用命令行执行的?Hadoop和Java的联系有哪些?
- Netty高并发上传文件问题
- 关于webwork中helloworld调试出错!!!请大侠们多多指教
- 在JAVA如何实现http请求的header字段的赋值?
在struts中添加数据源的做法是很不好的,违反了MVC的原则,应该在 App server中设置数据源的JNDI
这个tag即将在struts 2.x中被摈弃。
程序也会跑不起来。我们项目中也出现过这个问题。
如下是相关的源代码:
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>