@@ -64,14 +64,14 @@ Run with `Maven`:
64
64
<dependency >
65
65
<groupId >com.hellokaton</groupId >
66
66
<artifactId >blade-core</artifactId >
67
- <version >2.1.1.BETA </version >
67
+ <version >2.1.1.RELEASE </version >
68
68
</dependency >
69
69
```
70
70
71
71
or ` Gradle ` :
72
72
73
73
``` sh
74
- compile ' com.hellokaton:blade-core:2.1.1.BETA '
74
+ compile ' com.hellokaton:blade-core:2.1.1.RELEASE '
75
75
```
76
76
77
77
Write the ` main ` method and the ` Hello World ` :
@@ -99,6 +99,7 @@ Open http://localhost:9000 in your browser to see your first `Blade` application
99
99
- [ ** ` Get Cookie ` ** ] ( #get-cookie )
100
100
- [ ** ` Static Resource ` ** ] ( #static-resource )
101
101
- [ ** ` Upload File ` ** ] ( #upload-file )
102
+ - [ ** ` Download File ` ** ] ( #download-file )
102
103
- [ ** ` Set Session ` ** ] ( #set-session )
103
104
- [ ** ` Render To Browser ` ** ] ( #render-to-browser )
104
105
- [ ** ` Render Response ` ** ] ( #render-json )
@@ -397,8 +398,36 @@ public void upload(@Multipart FileItem fileItem){
397
398
}
398
399
```
399
400
401
+ ## Download File
402
+
403
+ ``` java
404
+ @GET (value = " /download" , responseType = ResponseType . STREAM )
405
+ public void download(Response response) throws IOException {
406
+ response. write(" abcd.pdf" , new File (" 146373013842336153820220427172437.pdf" ));
407
+ }
408
+ ```
409
+
410
+ ** If you want to preview certain files in your browser**
411
+
412
+ ``` java
413
+ @GET (value = " /preview" , responseType = ResponseType . PREVIEW )
414
+ public void preview(Response response) throws IOException {
415
+ response. write(new File (" 146373013842336153820220427172437.pdf" ));
416
+ }
417
+ ```
418
+
400
419
## Set Session
401
420
421
+ The session is disabled by default, you must enable the session.
422
+
423
+ ``` java
424
+ Blade . create()
425
+ .http(HttpOptions :: enableSession)
426
+ .start(Application . class, args);
427
+ ```
428
+
429
+ > 💡 It can also be enabled using a configuration file,` http.session.enabled=true `
430
+
402
431
``` java
403
432
public void login(Session session){
404
433
// if login success
@@ -554,7 +583,7 @@ The `hello.html` template
554
583
</html >
555
584
```
556
585
557
- [ Render API] ( http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA /com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView- )
586
+ [ Render API] ( http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE /com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView- )
558
587
559
588
## Redirects
560
589
@@ -565,7 +594,7 @@ public void redirectToGithub(RouteContext ctx){
565
594
}
566
595
```
567
596
568
- [ Redirect API] ( http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA /com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String- )
597
+ [ Redirect API] ( http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE /com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String- )
569
598
570
599
## Write Cookie
571
600
@@ -577,7 +606,7 @@ public void writeCookie(RouteContext ctx){
577
606
}
578
607
```
579
608
580
- [ Cookie API] ( http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.BETA /com/hellokaton/blade/mvc/http/Response.html#cookie-java.lang.String-java.lang.String- )
609
+ [ Cookie API] ( http://static.javadoc.io/com.hellokaton/blade-core/2.1.1.RELEASE /com/hellokaton/blade/mvc/http/Response.html#cookie-java.lang.String-java.lang.String- )
581
610
582
611
## Web Hook
583
612
0 commit comments