Hi all

I found a encoding question in the StringResourceStream, but it works fine
when I use the DynamicWebResource

-----StringResourceStream-----
@Override
        protected void init() {
                super.init();
                this.getMarkupSettings().setCompressWhitespace(true);
                this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
                
this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
                
this.getResourceSettings().setThrowExceptionOnMissingResource(false);
                this.mountSharedResource("/Test", new ResourceReference("Test") 
{
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected Resource newResource() {
                                return new Resource() {
                                        private static final long 
serialVersionUID = 1L;

                                        @Override
                                        public IResourceStream 
getResourceStream() {
                                                return new 
StringResourceStream("這是第一題");
                                        }
                                };
                        }
                }.getSharedResourceKey());
        }


-----StringResourceStream-----
@Override
        protected void init() {
                super.init();
                this.getMarkupSettings().setCompressWhitespace(true);
                this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
                
this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
                
this.getResourceSettings().setThrowExceptionOnMissingResource(false);
                this.mountSharedResource("/Test", new ResourceReference("Test") 
{
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected Resource newResource() {
                                return new DynamicWebResource() {
                                        private static final long 
serialVersionUID = 1L;

                                        @Override
                                        protected ResourceState 
getResourceState() {
                                                ResourceState state = new 
ResourceState() {

                                                        @Override
                                                        public String 
getContentType() {
                                                                return 
"text/html";
                                                        }

                                                        @Override
                                                        public byte[] getData() 
{
                                                                try {
                                                                        return 
"這是第一題".getBytes("UTF-8");
                                                                } catch 
(UnsupportedEncodingException e) {
                                                                        
e.printStackTrace();
                                                                }
                                                                return null;
                                                        }
                                                };
                                                return state;
                                        }
                                };
                        }
                }.getSharedResourceKey());
        }

Thanks!
-- 
View this message in context: 
http://www.nabble.com/StringBufferResourceStream-character-encoding-question-tp17998234p17998234.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to