Displaying keyword search results 1 - 10
Created by zhidao on January 25, 2012 19:27:53 Last update: January 25, 2012 19:28:47
The spring MVC annotation-driven declaration:
<?xml version="1.0" encoding="UTF-8"?> <beans x...does the following magic : Among others, registers: RequestMappingHandlerMapping RequestMappingHandlerAdapter ExceptionHandlerExceptionResolver in support of processing requests with annotated controller methods using annotations such as @RequestMapping , @ExceptionHandler , etc. Enables Spring 3 style type conversion through a ConversionService instance in addition to the JavaBeans PropertyEditors used for Data Binding. Enables support for formatting Number fields using the @NumberFormat annotation through the ConversionService . Enables support for formatting Date, Calendar, Long, and Joda Time fields using the @DateTimeFormat annotation, if Joda Time 1.3 or higher is present on the classpath. Enables support for validating @Controller inputs with @Valid , if a JSR-303 Provider is present on the classpath. Enables HttpMessageConverter support for @RequestBody method parameters and...
Created by Dr. Xi on February 12, 2010 22:52:27 Last update: November 08, 2011 19:48:09
For Tomcat 6, there's no default manager username and password. You do have to set it up yourself, though it's pretty straightforward. The Tomcat manager webapp is restricted to users with a role named manager . So you'll need to create a user and assign the manager role to it. Edit $CATALINA_BASE/conf/tomcat-users.xml to read:
<?xml version='1.0' encoding='utf-8'?> <!-- ...For tomcat 7:
<tomcat-users> <role rolename="manager"/> ...
Created by alfa on July 15, 2011 13:25:45 Last update: July 15, 2011 13:25:45
Read the whole contents of a file into a String. It's better to read the whole file as bytes and convert to String than to read the file line by line and concatenate the lines.
String getFileContents(String fileName) throws...Using java.nio :
import java.io.FileInputStream; import java...
Created by freyo on May 17, 2011 11:13:17 Last update: May 17, 2011 11:13:17
This is an odd-ball content provider in that it doesn't provide database records, but provides a resource as a stream. It can be used to provide media files or XML resources. Start the project with:
tools/android create project --package com.android...Create assets directory and add an XML file ( assets/demo.xml ):
<? xml version="1.0" encoding="UTF-8"?> <people...Edit the layout ( res/layout/main.xml ):
<?xml version="1.0" encoding="utf-8"?> <LinearL...Edit src/com/android/cptest/Dummy.java :
package com.android.cptest; import java.io....Add content provider ( src/com/android/cptest/XmlResource.java ):
package com.android.cptest; import java.io....Update AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?> <manifes...Add this section to the end of build.xml :
<target name="-package-resources"> <ech...Build and install:
ant installScreenshot: Remove the Dummy activity ( AndroidManifest.xml ):
<?xml version="1.0" encoding="utf-8"?> <manifes...Create a new project for...
Created by freyo on May 09, 2011 14:15:01 Last update: May 09, 2011 14:17:22
In short, use the PackageManager class to get the PackageInfo :
PackageInfo pkgInfo = getPackageManager().getP...To build an APK, make these changes to the greetings app : Change the layout to ( res/layout/main.xml ):
<?xml version="1.0" encoding="utf-8"?> <LinearL...Change the string values ( res/values/strings.xml ):
<?xml version="1.0" encoding="utf-8"?> <resourc...Update AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?> <manifes...Create a new Java class src/com/android/appinfo/GetAppVersion.java :
package com.android.appinfo; import android...Edit build.xml , change project name to "AppInfo":
<?xml version="1.0" encoding="UTF-8"?> <project...Install to emulator:
Created by Dr. Xi on April 27, 2011 08:28:31 Last update: April 27, 2011 08:37:40
JBoss example with hsql:
<persistence> <persistence-unit name="myapp"...MySQL example with JDBC :
<persistence xmlns="http://java.sun.com/xml...With OpenEJB transaction manager:
<persistence version="1.0" xmlns="...With EclipseLink :
<?xml version="1.0" encoding="UTF-8"?> <persist...
Created by Dr. Xi on March 02, 2011 11:39:18 Last update: March 09, 2011 12:19:30
Some peculiarities about Java PrintWriter: PrintWriter never throws any exceptions. From JavaDoc : Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError(). When error occurs, you'll never know anything more than that it occured, because checkError returns boolean. When a character is out of the range of the character encoding of the PrintWriter, it prints a question mark (?). But this is not an error. Test code:
import java.io.*; public class TestPrintWri...Latin1 test result:
java TestPrintWriter iso-8859-1 | od -bc 000000...UTF-8 test result:
java TestPrintWriter utf-8 | od -bc 0000000 141...Also, the constructor throws a FileNotFoundException when you try to write to a...
Created by nogeek on November 08, 2010 20:19:23 Last update: November 08, 2010 20:20:02
To tell the web server that it accepts GZIP encoding, a browser may send a header like this:
Accept-Encoding: gzip, deflate, compress;q=0.9What does the parameter q mean? By RFC2616 , the q parameter is an indicator of relative quality, with a range from 0 to 1 . For example:
Accept: audio/*; q=0.2, audio/basicmeans audio/basic is accepted with a q factor of 1 (since it's missing, the default value is 1), while audio/* is accepted with a q factor of 0.2 . In other words, audio/basic is five times as preferable as audio/* . Therefore, Accept-Encoding: gzip, deflate, compress;q=0.9 means that gzip and deflate are equally acceptable with a q factor of 1, but compress is accepted with a relatively lower "quality" factor of...
Created by Dr. Xi on August 30, 2010 18:17:15 Last update: August 30, 2010 18:19:49
Use the codecs module to read file in Unicode. This is from the Python doc :
import codecs f = codecs.open('unicode.rst', en...I had some luck reading files mainly in ASCII but contained some binary data with:
import codecs f = codecs.open('unicode.rst', en...
Created by voodoo on July 11, 2009 15:14:55 Last update: July 29, 2010 22:45:48
cURL is a command line tool for transferring files with URL syntax. The main purpose and use for cURL is to automate unattended file transfers or sequences of operations. It's really easy to see HTTP headers with curl:
C:\>curl --head http://www.google.com HTTP/1.0 ...or, headers and page together (dump headers to stdout):
$ curl --dump-header - http://www.google.com HTTP/...Download openssl from openssl.org:
C:\>curl --help Usage: curl [options...] <url> ...