File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
wicket/src/main/java/hellowicket/plaintext Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11package hellowicket .plaintext ;
22
3+ import java .nio .charset .Charset ;
4+
35import org .apache .wicket .request .resource .AbstractResource ;
46
57/**
@@ -10,15 +12,18 @@ public class HelloTextResource extends AbstractResource
1012{
1113 private static final long serialVersionUID = 1L ;
1214
15+ private static final String CONTENT_TYPE = "text/plain" ;
16+ private static final byte [] DATA = "Hello, World!" .getBytes (Charset .forName ("UTF-8" ));
17+
1318 protected ResourceResponse newResourceResponse (Attributes attributes )
1419 {
1520 ResourceResponse response = new ResourceResponse ();
16- response .setContentType ("text/plain" );
17- response .setContentLength (13 );
21+ response .setContentType (CONTENT_TYPE );
22+ response .setContentLength (DATA . length );
1823 response .setWriteCallback (new WriteCallback () {
1924 public void writeData (Attributes attributes )
2025 {
21- attributes .getResponse ().write ("Hello, World!" );
26+ attributes .getResponse ().write (DATA );
2227 }
2328 });
2429 return response ;
You can’t perform that action at this time.
0 commit comments