Skip to content

Commit cf36682

Browse files
committed
JFinal 1.3 Release :)
1 parent 18d95fd commit cf36682

22 files changed

+124
-34
lines changed

WebRoot/WEB-INF/lib/1_lib_description.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,36 @@ JFinal 自身对第三方无依赖,但当需要第三方功能支持时则需
55
2:jetty-server-8.1.8.jar 用来支持无需额外安装 tomcat jetty 等 web server
66
即可开始开发,同时它也是支持热部署的必要包。jetty-server-8.1.8.jar 中
77
包含:jetty-8.1.8发行版"/lib"目录下所有jetty模块jar包、servlet-api-3.0.jar、
8-
"/lib/jsp"下所有jar包。
8+
"/lib/jsp"下的 com.sun.el-2.2.0.v201108011116.jar、
9+
javax.el-2.2.0.v201108011116.jar、javax.servlet.jsp-2.2.0.v201112011158.jar
10+
org.apache.jasper.glassfish-2.2.2.v201112011158.jar
911

1012
3:freemarker-2.3.16.jar 支持 FreeMarker 视图类型。
1113

12-
4:velocity-1.7.jar、velocity-1.7-dep.jar支持 Velocity 视图。
14+
4:javax.servlet.jsp.jstl-1.2.0.v201105211821.jar 与
15+
org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
16+
支持 jsp 视图类型
1317

14-
5:cos-26Dec2008.jar 支持文件上传功能
18+
5:velocity-1.7.jar、velocity-1.7-dep.jar支持 Velocity 视图
1519

16-
6:mysql-connector-java-5.1.20-bin.jar 支持 mysql 数据库
20+
6:cos-26Dec2008.jar 支持文件上传功能
1721

18-
7:c3p0-0.9.1.2.jar 数据库连接池
22+
7:mysql-connector-java-5.1.20-bin.jar 支持 mysql 数据库
1923

20-
8:ehcache-core-2.5.2.jar、slf4j-api-1.6.1.jar、slf4j-log4j12-1.6.1.jar 支持 EhCache。
24+
8:c3p0-0.9.1.2.jar 数据库连接池。
25+
26+
9:ehcache-core-2.5.2.jar、slf4j-api-1.6.1.jar、slf4j-log4j12-1.6.1.jar 支持 EhCache。
2127
在使用EhCache时需要有ehcache.xml文件。
2228

23-
9:以org.springframework 打头的所有 jar 包支持 SpringPlugin
29+
10:以org.springframework 打头的所有 jar 包支持 SpringPlugin
2430

25-
10:sqlite-jdbc-3.7.2.jar 支持 Sqlite 数据库
31+
11:sqlite-jdbc-3.7.2.jar 支持 Sqlite 数据库
2632

27-
11:druid-0.2.6.jar 支持 Druid 数据库连接池
33+
12:druid-0.2.6.jar 支持 Druid 数据库连接池
2834

29-
12:ojdbc6.jar Oracle Database 11g Release 2 (11.2.0.3) JDBC Driver
35+
13:ojdbc6.jar Oracle Database 11g Release 2 (11.2.0.3) JDBC Driver
3036

31-
13:log4j-1.2.16.jar 支持 log4j 日志,当此文件不存在时,自动切换至 JDK Logger,
37+
14:log4j-1.2.16.jar 支持 log4j 日志,当此文件不存在时,自动切换至 JDK Logger,
3238
注意,log4j需要相应的配置文件 log4j.properties,否则当log4j-1.2.16.jar 存在
3339
而log4j.properties 不存在时无日志输出。jdk logger 需要的logging.properties文件
3440
也在此目录下提供了

src/com/jfinal/core/Const.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public interface Const {
2626

27-
String JFINAL_VERSION = "1.2";
27+
String JFINAL_VERSION = "1.3";
2828

2929
ViewType DEFAULT_VIEW_TYPE = ViewType.FREE_MARKER;
3030

src/com/jfinal/core/JFinal.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ public final class JFinal {
4444
private Handler handler;
4545
private ServletContext servletContext;
4646
private static IServer server;
47+
private String contextPath = "";
4748

4849
Handler getHandler() {
4950
return handler;
5051
}
5152

5253
private static final JFinal me = new JFinal();
5354

54-
// singleton
5555
private JFinal() {
5656
}
5757

@@ -61,6 +61,7 @@ public static JFinal me() {
6161

6262
boolean init(JFinalConfig jfinalConfig, ServletContext servletContext) {
6363
this.servletContext = servletContext;
64+
this.contextPath = servletContext.getContextPath();
6465

6566
initPathUtil();
6667

@@ -198,6 +199,10 @@ public Constants getConstants() {
198199
public Action getAction(String url, String[] urlPara) {
199200
return actionMapping.getAction(url, urlPara);
200201
}
202+
203+
public String getContextPath() {
204+
return contextPath;
205+
}
201206
}
202207

203208

src/com/jfinal/plugin/activerecord/TableInfoMapping.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class TableInfoMapping {
2828

2929
private static TableInfoMapping me = new TableInfoMapping();
3030

31-
// singleton
3231
private TableInfoMapping() {
3332
}
3433

src/com/jfinal/plugin/activerecord/tx/Tx.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void intercept(ActionInvocation invocation) {
3939
Connection conn = null;
4040
Boolean autoCommit = null;
4141
try {
42-
conn = DbKit.getDataSource().getConnection();
42+
conn = DbKit.getConnection();
4343
autoCommit = conn.getAutoCommit();
4444
DbKit.setThreadLocalConnection(conn);
4545
conn.setTransactionIsolation(getTransactionLevel()); // conn.setTransactionIsolation(transactionLevel);

src/com/jfinal/plugin/ehcache/CacheInterceptor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ final public void intercept(ActionInvocation ai) {
7373
useCacheDataAndRender(cacheData, controller);
7474
}
7575

76+
// TODO 考虑与 EvictInterceptor 一样强制使用 @CacheName
7677
private String buildCacheName(ActionInvocation ai, Controller controller) {
7778
CacheName cacheName = ai.getMethod().getAnnotation(CacheName.class);
7879
if (cacheName != null)
7980
return cacheName.value();
8081
cacheName = controller.getClass().getAnnotation(CacheName.class);
81-
if (cacheName != null)
82-
return cacheName.value();
83-
return ai.getActionKey();
82+
return (cacheName != null) ? cacheName.value() : ai.getActionKey();
8483
}
8584

8685
private String buildCacheKey(ActionInvocation ai, Controller controller) {

src/com/jfinal/plugin/ehcache/CacheName.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright (c) 2011-2012, James Zhan 詹波 (jfinal@126.com).
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.jfinal.plugin.ehcache;
218

319
import java.lang.annotation.ElementType;
@@ -7,7 +23,7 @@
723
import java.lang.annotation.Target;
824

925
/**
10-
* CacheName can configure CacheInterceptor's cache name.
26+
* CacheName can configure CacheInterceptor's cache name or EvictInterceptor's evict cache name.
1127
* <p>
1228
* The order of CacheInterceptor searching for CacheName annotation:<br>
1329
* 1: Action method of current invocation<br>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright (c) 2011-2012, James Zhan 詹波 (jfinal@126.com).
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.jfinal.plugin.ehcache;
18+
19+
import com.jfinal.aop.Interceptor;
20+
import com.jfinal.core.ActionInvocation;
21+
import com.jfinal.core.Controller;
22+
23+
/**
24+
* EvictInterceptor.
25+
*/
26+
public class EvictInterceptor implements Interceptor {
27+
28+
final public void intercept(ActionInvocation ai) {
29+
ai.invoke();
30+
31+
String cacheName = buildCacheName(ai, ai.getController());
32+
CacheKit.removeAll(cacheName);
33+
}
34+
35+
private String buildCacheName(ActionInvocation ai, Controller controller) {
36+
CacheName cacheName = ai.getMethod().getAnnotation(CacheName.class);
37+
if (cacheName != null)
38+
return cacheName.value();
39+
40+
cacheName = controller.getClass().getAnnotation(CacheName.class);
41+
if (cacheName == null)
42+
throw new RuntimeException("EvictInterceptor need CacheName annotation in controller.");
43+
return cacheName.value();
44+
}
45+
}
46+

src/com/jfinal/render/Error404Render.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public class Error404Render extends Render {
2828

29-
private static final long serialVersionUID = 1764764489766904795L;
29+
private static final long serialVersionUID = 3925763221184467994L;
3030
private static final String contentType = "text/html;charset=" + getEncoding();
3131
private static final String defaultHtml = "<html><head><title>404 Not Found</title></head><body bgcolor='white'><center><h1>404 Not Found</h1></center><hr><center><a href='http://www.jfinal.com'>JFinal/" + Const.JFINAL_VERSION + "</a></center></body></html>";
3232

src/com/jfinal/render/Error500Render.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public class Error500Render extends Render {
2828

29-
private static final long serialVersionUID = 4864834986049401413L;
29+
private static final long serialVersionUID = -7993459890626145958L;
3030
private static final String contentType = "text/html;charset=" + getEncoding();
3131
private static final String defaultHtml = "<html><head><title>500 Internal Server Error</title></head><body bgcolor='white'><center><h1>500 Internal Server Error</h1></center><hr><center><a href='http://www.jfinal.com'>JFinal/" + Const.JFINAL_VERSION + "</a></center></body></html>";
3232

src/com/jfinal/render/FileRender.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.IOException;
2323
import java.io.InputStream;
2424
import java.io.OutputStream;
25+
import java.io.UnsupportedEncodingException;
2526
import javax.servlet.ServletContext;
2627
import static com.jfinal.core.Const.DEFAULT_FILE_CONTENT_TYPE;
2728
import com.jfinal.kit.PathKit;
@@ -31,7 +32,7 @@
3132
*/
3233
public class FileRender extends Render {
3334

34-
private static final long serialVersionUID = -627386273750207255L;
35+
private static final long serialVersionUID = 4293616220202691369L;
3536
private File file;
3637
private String fileName;
3738
private static String fileDownloadPath;
@@ -69,7 +70,12 @@ public void render() {
6970
return ;
7071
}
7172

72-
response.addHeader("Content-disposition", "attachment; filename=" + file.getName());
73+
try {
74+
response.addHeader("Content-disposition", "attachment; filename=" + new String(file.getName().getBytes("GBK"), "ISO8859-1"));
75+
} catch (UnsupportedEncodingException e) {
76+
response.addHeader("Content-disposition", "attachment; filename=" + file.getName());
77+
}
78+
7379
String contentType = servletContext.getMimeType(file.getName());
7480
if (contentType == null) {
7581
contentType = DEFAULT_FILE_CONTENT_TYPE; // "application/octet-stream";

src/com/jfinal/render/FreeMarkerRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
public class FreeMarkerRender extends Render {
3636

37-
private static final long serialVersionUID = 3959102981898502071L;
37+
private static final long serialVersionUID = -7649769283048920381L;
3838
private transient static final String encoding = getEncoding();
3939
private transient static final String contentType = "text/html; charset=" + encoding;
4040
private transient static final Configuration config = new Configuration();

src/com/jfinal/render/HtmlRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public class HtmlRender extends Render {
2626

27-
private static final long serialVersionUID = -1805855373995133760L;
27+
private static final long serialVersionUID = 8145891655998147406L;
2828
private static final String contentType = "text/html;charset=" + getEncoding();
2929
private String text;
3030

src/com/jfinal/render/JavascriptRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public class JavascriptRender extends Render {
2626

27-
private static final long serialVersionUID = 3378793486917573848L;
27+
private static final long serialVersionUID = 8559524286644647476L;
2828
private static final String contentType = "text/javascript;charset=" + getEncoding();
2929
private String jsText;
3030

src/com/jfinal/render/JsonRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
public class JsonRender extends Render {
3333

34-
private static final long serialVersionUID = 6970249421567251974L;
34+
private static final long serialVersionUID = 3606364198859021837L;
3535

3636
/**
3737
* http://zh.wikipedia.org/zh/MIME

src/com/jfinal/render/JspRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@SuppressWarnings({"rawtypes", "unchecked"})
3434
public class JspRender extends Render {
3535

36-
private static final long serialVersionUID = 4979806661797436765L;
36+
private static final long serialVersionUID = -688478484751775667L;
3737
private transient static boolean isSupportActiveRecord = true;
3838

3939
public static void setSupportActiveRecord(boolean supportActiveRecord) {

src/com/jfinal/render/NullRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
public class NullRender extends Render {
2323

24-
private static final long serialVersionUID = -389288806463724481L;
24+
private static final long serialVersionUID = 4383753964688920354L;
2525

2626
/**
2727
* Render nothing

src/com/jfinal/render/Redirect301Render.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
*/
2424
public class Redirect301Render extends Render {
2525

26-
private static final long serialVersionUID = -6822589387282014944L;
26+
private static final long serialVersionUID = -115860447207423482L;
2727
private String url;
2828
private boolean withQueryString;
29+
private static final String contextPath = RedirectRender.getContxtPath();
2930

3031
public Redirect301Render(String url) {
3132
this.url = url;
@@ -38,6 +39,9 @@ public Redirect301Render(String url, boolean withQueryString) {
3839
}
3940

4041
public void render() {
42+
if (contextPath != null && url.indexOf("://") == -1)
43+
url = contextPath + url;
44+
4145
if (withQueryString) {
4246
String queryString = request.getQueryString();
4347
if (queryString != null)

src/com/jfinal/render/RedirectRender.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@
1717
package com.jfinal.render;
1818

1919
import java.io.IOException;
20+
import com.jfinal.core.JFinal;
2021

2122
/**
2223
* RedirectRender with status: 302 Found.
2324
*/
2425
public class RedirectRender extends Render {
2526

26-
private static final long serialVersionUID = -3120354341585834890L;
27+
private static final long serialVersionUID = 1812102713097864255L;
2728
private String url;
2829
private boolean withQueryString;
30+
private static final String contextPath = getContxtPath();
31+
32+
static String getContxtPath() {
33+
String cp = JFinal.me().getContextPath();
34+
return ("".equals(cp) || "/".equals(cp)) ? null : cp;
35+
}
2936

3037
public RedirectRender(String url) {
3138
this.url = url;
@@ -38,6 +45,9 @@ public RedirectRender(String url, boolean withQueryString) {
3845
}
3946

4047
public void render() {
48+
if (contextPath != null && url.indexOf("://") == -1)
49+
url = contextPath + url;
50+
4151
if (withQueryString) {
4252
String queryString = request.getQueryString();
4353
if (queryString != null)

src/com/jfinal/render/RenderFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static ServletContext getServletContext() {
3636
return servletContext;
3737
}
3838

39-
// singleton
4039
private static final RenderFactory me = new RenderFactory();
4140

4241
private RenderFactory() {

src/com/jfinal/render/TextRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public class TextRender extends Render {
2626

27-
private static final long serialVersionUID = -5264892635310241831L;
27+
private static final long serialVersionUID = 4775148244778489992L;
2828
private static final String defaultContentType = "text/plain;charset=" + getEncoding();
2929
private String text;
3030

src/com/jfinal/render/VelocityRender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
public class VelocityRender extends Render {
3636

37-
private static final long serialVersionUID = 2195369405439638708L;
37+
private static final long serialVersionUID = 1012573049421601960L;
3838
private transient static final String encoding = getEncoding();
3939
private transient static final String contentType = "text/html;charset=" + encoding;
4040
private transient static final Properties properties = new Properties();

0 commit comments

Comments
 (0)