- 浏览: 116388 次
- 性别:
- 来自: 武汉
-
文章分类
- 全部博客 (98)
- java (27)
- jms (2)
- jta (0)
- 性能调优及内存分析 (4)
- 设计模式 (14)
- 框架 (6)
- 其它 (9)
- job (1)
- maven (1)
- 服务器 (2)
- 分布式 (3)
- ibatis (1)
- linux (0)
- mysql (0)
- 并发编程 (0)
- java多线程 (2)
- 前端跨域 (1)
- 线程dump分析 (0)
- velocity (0)
- 数据库 (2)
- 协议 (0)
- 监控 (0)
- 开源软件 (2)
- 算法 (0)
- 网络 (1)
- spring (1)
- 编码 (0)
- 数据结构 (0)
- HTable和HTablePool使用注意事项 (0)
- opencms (0)
- android (16)
- 操作系统 (2)
- top (0)
最新评论
-
hold_on:
@Override public boolea ...
android listview的HeadView左右切换图片(仿新浪,网易,百度等切换图片) -
achersnake:
123
Servlet中listener(监听器)和filter的总结 -
angel243fly:
我用了这个方法,还是报同样的错误,还有什么建议吗?
eclipse提示CreateProcess error=87错误的解决方法
转: http://blog.csdn.net/accpsz/archive/2010/12/31/6108917.aspx
// return above and flow through again
if (!executed) {
//在Result返回之前调用preResultListeners
if (preResultListeners != null) {
for (Iterator iterator = preResultListeners.iterator();
iterator.hasNext();) {
PreResultListener listener = (PreResultListener) iterator.next();
String _profileKey="preResultListener: ";
try {
UtilTimerStack.push(_profileKey);
listener.beforeResult(this, resultCode);
}
finally {
UtilTimerStack.pop(_profileKey);
}
}
}
// now execute the result, if we're supposed to
if (proxy.getExecuteResult()) {
executeResult();
}
executed = true;
}
return resultCode;
}
finally {
UtilTimerStack.pop(profileKey);
}
}
String methodName = proxy.getMethod();
String timerKey = "invokeAction: "+proxy.getActionName();
try {
UtilTimerStack.push(timerKey);
boolean methodCalled = false;
Object methodResult = null;
Method method = null;
try {
//获得需要执行的方法
method = getAction().getClass().getMethod(methodName, new Class[0]);
} catch (NoSuchMethodException e) {
//如果没有对应的方法,则使用do+Xxxx来再次获得方法
try {
String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
method = getAction().getClass().getMethod(altMethodName, new Class[0]);
} catch (NoSuchMethodException e1) {
// well, give the unknown handler a shot
if (unknownHandler != null) {
try {
methodResult = unknownHandler.handleUnknownActionMethod(action, methodName);
methodCalled = true;
} catch (NoSuchMethodException e2) {
// throw the original one
throw e;
}
} else {
throw e;
}
}
}
if (!methodCalled) {
methodResult = method.invoke(action, new Object[0]);
}
//根据不同的Result类型返回不同值
//如输出流Result
if (methodResult instanceof Result) {
this.explicitResult = (Result) methodResult;
return null;
} else {
return (String) methodResult;
}
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("The " + methodName + "() is not defined in action " + getAction().getClass() + "");
} catch (InvocationTargetException e) {
// We try to return the source exception.
Throwable t = e.getTargetException();
if (actionEventListener != null) {
String result = actionEventListener.handleException(t, getStack());
if (result != null) {
return result;
}
}
if (t instanceof Exception) {
throw(Exception) t;
} else {
throw e;
}
} finally {
UtilTimerStack.pop(timerKey);
}
}
//根据ResultConfig创建Result
result = createResult();
String timerKey = "executeResult: "+getResultCode();
try {
UtilTimerStack.push(timerKey);
if (result != null) {
//这儿正式执行:)
//可以参考Result的实现,如用了比较多的ServletDispatcherResult,ServletActionRedirectResult,ServletRedirectResult
result.execute(this);
} else if (resultCode != null && !Action.NONE.equals(resultCode)) {
throw new ConfigurationException("No result defined for action " + getAction().getClass().getName()
+ " and result " + getResultCode(), proxy.getConfig());
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("No result returned for action "+getAction().getClass().getName()+" at "+proxy.getConfig().getLocation());
}
}
} finally {
UtilTimerStack.pop(timerKey);
}
}
public Result createResult() throws Exception {
if (explicitResult != null) {
Result ret = explicitResult;
explicitResult = null;;
return ret;
}
ActionConfig config = proxy.getConfig();
Map results = config.getResults();
ResultConfig resultConfig = null;
synchronized (config) {
try {
//根据result名称获得ResultConfig,resultCode就是result的name
resultConfig = (ResultConfig) results.get(resultCode);
} catch (NullPointerException e) {
}
if (resultConfig == null) {
//如果找不到对应name的ResultConfig,则使用name为*的Result
resultConfig = (ResultConfig) results.get("*");
}
}
if (resultConfig != null) {
try {
//参照StrutsObjectFactory的代码
Result result = objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
return result;
} catch (Exception e) {
LOG.error("There was an exception while instantiating the result of type " + resultConfig.getClassName(), e);
throw new XWorkException(e, resultConfig);
}
} else if (resultCode != null && !Action.NONE.equals(resultCode) && unknownHandler != null) {
return unknownHandler.handleUnknownResult(invocationContext, proxy.getActionName(), proxy.getConfig(), resultCode);
}
return null;
}
//StrutsObjectFactory
public Result buildResult(ResultConfig resultConfig, Map extraContext) throws Exception {
String resultClassName = resultConfig.getClassName();
if (resultClassName == null)
return null;
//创建Result,因为Result是有状态的,所以每次请求都新建一个
Object result = buildBean(resultClassName, extraContext);
//这句很重要,后面将会谈到,reflectionProvider参见OgnlReflectionProvider;
//resultConfig.getParams()就是result配置文件里所配置的参数<param></param>
//setProperties方法最终调用的是Ognl类的setValue方法
//这句其实就是把param名值设置到根对象result上
reflectionProvider.setProperties(resultConfig.getParams(), result, extraContext);
if (result instanceof Result)
return (Result) result;
throw new ConfigurationException(result.getClass().getName() + " does not implement Result.");
}
private User user;
private Map context;
@Before
public void setUp() throws Exception {
}
@Test
public void ognlGetValue() throws Exception {
reset();
Assert.assertEquals("myyate", Ognl.getValue("name", user));
Assert.assertEquals("cares", Ognl.getValue("dept.name", user));
Assert.assertEquals("myyate", Ognl.getValue("name", context, user));
Assert.assertEquals("contextmap", Ognl.getValue("#name", context, user));
Assert.assertEquals("parker", Ognl.getValue("#pen", context, user));
}
@Test
public void ognlSetValue() throws Exception {
reset();
Ognl.setValue("name", user, "myyateC");
Assert.assertEquals("myyateC", Ognl.getValue("name", user));
Ognl.setValue("dept.name", user, "caresC");
Assert.assertEquals("caresC", Ognl.getValue("dept.name", user));
Assert.assertEquals("contextmap", Ognl.getValue("#name", context, user));
Ognl.setValue("#name", context, user, "contextmapC");
Assert.assertEquals("contextmapC", Ognl.getValue("#name", context, user));
Assert.assertEquals("parker", Ognl.getValue("#pen", context, user));
Ognl.setValue("#name", context, user, "parkerC");
Assert.assertEquals("parkerC", Ognl.getValue("#name", context, user));
}
public static void main(String[] args) throws Exception {
JUnitCore.runClasses(TestOgnl.class);
}
private void reset() {
user = new User("myyate", new Dept("cares"));
context = new OgnlContext();
context.put("pen", "parker");
context.put("name", "contextmap");
}
}
class User {
public User(String name, Dept dept) {
this.name = name;
this.dept = dept;
}
String name;
private Dept dept;
public Dept getDept() {
return dept;
}
public String getName() {
return name;
}
public void setDept(Dept dept) {
this.dept = dept;
}
public void setName(String name) {
this.name = name;
}
}
class Dept {
public Dept(String name) {
this.name = name;
}
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
发表评论
-
用Berkeley DB实现的BdbFrontier
2012-04-12 17:38 0简单的说,Berkeley DB就 ... -
不简单的URL去重
2012-04-12 16:21 0转:http://blog.csdn.net/hist ... -
如何读开源框架源码
2011-04-17 13:25 1549转:http://benbear2008.iteye.com/ ... -
Log4j使用总结
2011-04-15 16:58 784转:http://kdboy.iteye.com/blog/2 ... -
Commons-logging + Log4j 入门指南(part2)
2011-04-15 16:56 972为什么说“CONSOLE”表示将日志信息输出到“控制台”呢?那 ... -
Commons-logging + Log4j 入门指南(part1)
2011-04-15 16:52 693转:http://touch.iteye.com/blog/3 ... -
struts2源码分析1(part1)
2011-04-09 15:50 917转:http://blog.csdn.net/ ...
相关推荐
6. **源码分析**: 要深入理解Struts2的文件上传机制,你需要查看Struts2的源码,特别是`org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest`和`org.apache.struts2.components.Form`这两个类。...
这个"struts-2.3.8-all-part1"压缩包包含了Struts 2框架的完整版本,版本号为2.3.8。由于文件较大,所以被分为两个部分上传,这部分是第一部分,包括了`apps`, `docs`, `src`, `lib`等关键目录。接下来,我们将深入...
4. **源码分析** - `struts2_01_014_FileUp`可能是一个具体的Action类,负责处理上传和下载操作。它可能包含了处理文件路径、文件名、文件内容的逻辑。 - 源码中可能涉及到的其他组件包括:表单验证、异常处理、...
9. **源码分析** 对于深入理解Struts2文件上传的工作原理,阅读源码是非常有帮助的。了解`FileUploadInterceptor`如何工作,以及`MultipartRequest`类如何解析Multipart请求,可以加深对整个过程的理解。 10. **...
压缩包中的三个文件`JasperReportTest.part2.rar`、`JasperReportTest.part1.rar`和`JasperReportTest.part3.rar`很可能是分片的文件,你需要使用合适的工具(如WinRAR或7-Zip)将它们合并成一个完整的JasperReport...
**(1)配置Struts2拦截器** 在struts.xml配置文件中,为使用SWFupload的Action添加特定的拦截器链,以避免Struts2默认的文件上传处理。可以创建一个新的Interceptor,例如`swfUploadInterceptor`,然后在Action配置...
【JSP源码工程文件(part1)】是一个包含了使用Struts和Hibernate框架开发的Java Web项目的源代码。这个项目提供了对JSP技术的深入理解,同时也展现了如何将MVC设计模式通过Struts框架实现,以及如何利用Hibernate...
1. **MVC设计模式**:了解Struts如何实现请求分发,Spring如何处理业务逻辑和视图渲染。 2. **Spring框架**:研究Spring的IoC容器是如何管理对象的生命周期和依赖关系,以及AOP在事务管理和日志记录中的应用。 3. ...
1. **MVC框架**:这部分源码可能使用了Spring MVC或Struts2等MVC架构,用于实现业务逻辑和视图的分离,提高代码可维护性。 2. **用户认证与授权**:通过例如Spring Security或Apache Shiro,实现用户登录、权限控制...
通过分析代码、运行示例和调试问题,你可以深入了解J2EE架构的工作原理,同时提高自己的编程能力。此外,与课堂笔记结合学习,将更全面地理解项目背后的理论知识。在实践中遇到问题时,可以参考李兴华在CSDN上的分享...
你可以通过分析Action类、Interceptor、配置文件(struts.xml)等内容,深入理解Struts2如何与Servlet协同工作,完成文件的上传下载操作。此外,还可能涉及到异常处理、文件路径管理、安全性(防止恶意文件上传)等...
1:外文原文 Struts——an open-source MVC implementation This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help...
通过阅读《精通Spring(清晰书签版)》.part1.rar和.part2.rar这两个压缩包文件,你将能系统地学习和掌握Spring框架的各个方面,提升自己的Java EE开发能力。这本书的内容详实,实例丰富,是Spring学习者不可多得的...
9. **源码分析**:SWFUpload本身是开源的,熟悉其源码可以帮助开发者更好地理解和定制功能。 10. **工具集成**:SWFUpload可以与各种Java Web框架(如Spring MVC、Struts2)集成,理解这些框架如何处理文件上传会更...
8. **源码分析**:作为一个开源工具,jspsmart的源码可供开发者学习和定制,你可以深入理解其内部实现,根据项目需求进行扩展或优化。 9. **整合框架**:在实际开发中,jspsmart常与Spring MVC、Struts2等Web框架...
源码分析 `Commons FileUpload`的源码对于深入理解其工作原理和优化文件上传处理很有帮助。通过阅读源码,我们可以学习如何解析MIME数据流,如何管理内存与磁盘之间的切换,以及如何处理各种异常情况。 ### 7. ...
7. **源码分析** 对于开发者来说,阅读Apache Commons FileUpload的源码有助于深入理解文件上传的过程。例如,可以了解如何解析多部分数据的边界,以及如何处理内存和磁盘的交互。 8. **工具集成** 除了直接使用...
初学者可以通过分析系统源码了解JSP页面的基本构成。 2. **JSP脚本元素**:包括脚本声明(! %>)、脚本表达式()和脚本语句(),在系统中可能用于定义变量、输出数据或执行控制逻辑。 3. **JSP内置对象**:如`...