[2/2] struts-site git commit: Export JSON plugin page
Export JSON plugin page Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/4221720d Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/4221720d Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/4221720d Branch: refs/heads/master Commit: 4221720d2c925c8e6dfff67558779020d07c60be Parents: 271ed7b Author: Lukasz Lenart Authored: Tue Sep 12 12:00:23 2017 +0200 Committer: Lukasz Lenart Committed: Tue Sep 12 12:01:10 2017 +0200 -- pom.xml | 4 +- source/plugins/json/index.md | 639 ++ 2 files changed, 641 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/4221720d/pom.xml -- diff --git a/pom.xml b/pom.xml index 420bb63..30d6d8e 100644 --- a/pom.xml +++ b/pom.xml @@ -94,14 +94,14 @@ -a ${project.build.directory}/md/attachments -o - ${project.build.directory}/md/junit-plugin.md + ${project.build.directory}/md/json-plugin.md -u ${confluence.user}:${confluence.password} -server https://cwiki.apache.org/confluence +gfm true -2330106 +2850922 http://git-wip-us.apache.org/repos/asf/struts-site/blob/4221720d/source/plugins/json/index.md -- diff --git a/source/plugins/json/index.md b/source/plugins/json/index.md new file mode 100644 index 000..7586ccf --- /dev/null +++ b/source/plugins/json/index.md @@ -0,0 +1,639 @@ +--- +layout: plugin +title: Convention plugin +--- + +# JSON Plugin +{:.no_toc} + +* Will be replaced with the ToC, excluding a header +{:toc} + +## Description + +The JSON plugin provides a `json` result type that serializes actions into JSON + +1. The `content-type` must be `application/json` +2. The JSON content must be well formed, see [json.org](http://www.json.org) for grammar. +3. Action must have a public "setter" method for fields that must be populated. +4. Supported types for population are: Primitives (int,long...String), Date, List, Map, Primitive Arrays, + other class (more on this later), and Array of Other class. +5. Any object in JSON, that is to be populated inside a list, or a map, will be of type Map (mapping from properties + to values), any whole number will be of type Long, any decimal number will be of type Double, and any array of type List. + +Given this JSON string: + +```json +{ + "doubleValue": 10.10, + "nestedBean": { + "name": "Mr Bean" + }, + "list": ["A", 10, 20.20, { + "firstName": "El Zorro" + }], + "array": [10, 20] +} +``` + +The action must have a `setDoubleValue` method, taking either a `float` or a `double` argument (the interceptor will +convert the value to the right one). There must be a `setNestedBean` whose argument type can be any class, that has +a `setName` method taking as argument an `String`. There must be a `setList` method that takes a `List` as argument, +that list will contain: "A" (`String`), 10 (`Long`), 20.20 (`Double`), Map (`firstName` -> `El Zorro`). +The `setArray` method can take as parameter either a `List`, or any numeric array. + +> So serialize your objects to JSON in javascript see [json2](http://json.org/json2.js). + +`root` attribute must be set on the `JSONInterceptor` when dealing with JSON array. + +This plugin also provides _AJAX Validation_. + +## Installation + +This plugin can be installed by copying the plugin jar into your application's `/WEB-INF/lib` directory. No other +files need to be copied or created. + +To use maven, add this to your pom: + +```xml + + ... + + org.apache.struts + struts2-json-plugin + STRUTS_VERSION + + ... + +``` + +## Customizing Serialization and Deserialization + +Use the JSON annotation to customize the serialization/deserialization process. Available JSON annotation fields: + +|Name|Description|Default Value|Serialization|Deserialization| +||---|-|-|---| +|name|Customize field name|empty|yes|no| +|serialize|Include in serialization|true|yes|no| +|deserialize|Include in deserialization
[1/2] struts-site git commit: Adds JSON plugin to the list
Repository: struts-site Updated Branches: refs/heads/master 271ed7b46 -> a62c7745a Adds JSON plugin to the list Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/a62c7745 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/a62c7745 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/a62c7745 Branch: refs/heads/master Commit: a62c7745ab79c0a30df567b84b3aa4a8119bcb18 Parents: 4221720 Author: Lukasz Lenart Authored: Tue Sep 12 12:01:05 2017 +0200 Committer: Lukasz Lenart Committed: Tue Sep 12 12:01:10 2017 +0200 -- source/plugins/index.md | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/a62c7745/source/plugins/index.md -- diff --git a/source/plugins/index.md b/source/plugins/index.md index 653e591..e7f7f93 100644 --- a/source/plugins/index.md +++ b/source/plugins/index.md @@ -6,5 +6,6 @@ title: Plugins (WIP) # Plugins - [Convention plugin](convention/) + - [JSON plugin](json/) - [JUnit plugin](junit/) \ No newline at end of file
struts-site git commit: Updates production by Jenkins
Repository: struts-site Updated Branches: refs/heads/asf-site 740bd3f6d -> 77840af47 Updates production by Jenkins Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/77840af4 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/77840af4 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/77840af4 Branch: refs/heads/asf-site Commit: 77840af477a698dde0edec39988c5646f3953c4f Parents: 740bd3f Author: jenkins Authored: Tue Sep 12 10:01:49 2017 + Committer: jenkins Committed: Tue Sep 12 10:01:49 2017 + -- content/plugins/index.html | 1 + content/plugins/json/index.html | 893 +++ 2 files changed, 894 insertions(+) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/77840af4/content/plugins/index.html -- diff --git a/content/plugins/index.html b/content/plugins/index.html index 0391bc5..866108f 100644 --- a/content/plugins/index.html +++ b/content/plugins/index.html @@ -128,6 +128,7 @@ Convention plugin + JSON plugin JUnit plugin http://git-wip-us.apache.org/repos/asf/struts-site/blob/77840af4/content/plugins/json/index.html -- diff --git a/content/plugins/json/index.html b/content/plugins/json/index.html new file mode 100644 index 000..84274cb --- /dev/null +++ b/content/plugins/json/index.html @@ -0,0 +1,893 @@ + + + + + + + + + + Convention plugin + + + + + + + + + + + + + +http://github.com/apache/struts"; class="github-ribbon"> + https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa.png"; alt="Fork me on GitHub"> + + + + + + + + +Menu +Toggle navigation + + + + + + + + + + +Home + + +Welcome +Downloads +Announcements +http://www.apache.org/licenses/";>License +http://apache.org/foundation/thanks.html";>Thanks! +http://apache.org/foundation/sponsorship.html";>Sponsorship + + + + +Support + + +User Mailing List +https://issues.apache.org/jira/browse/WW";>Issue Tracker +Reporting Security Issues + +Project info +Struts Core dependencies +Plugin dependencies + + + + +Documentation + + +Birds Eye +Key Technologies +Kickstart FAQ +https://cwiki.apache.org/confluence/display/WW/Home";>Wiki + +Getting Started +Security Guide +Core Developers Guide +Plugins + +Struts Core API +Plugin APIs +Tag reference +http://cwiki.apache.org/S2PLUGINS/home.html";>Plugin registry + +Tutorials - DEPRECATED +FAQs - DEPRECATED +Guides - DEPRECATED + + + + +Contributing + + +You at Struts +How to Help FAQ +Development Lists + +Submitting patches +Source Code +Coding standards + +Release Guidelines +PMC Charter +Volunteers +https://git-wip-us.apache.org/repos/asf?p=struts.git";>Source Repository + + +http://www.apache.org/";> + + + + + + + + + + +<< back to Plugins +https://github.com/apache/struts-site/edit/master/source/plugins/json/index.md"; title="Edit this page on GitHub">Edit on GitHub +JSON Plugin + + + Description + Installation + Customizing Serialization and Deserialization + Excluding properties + Including properties + Root Object + Wrapping + Prefix + Base Classes + Enumerations + Compressing the output + Preventing the browser from caching the response + Excluding properties with null values + Status and Error code + JSONP + Content Type + Encoding + + + Example + Setup Action + Writ
struts-site git commit: Update PlainText result page
Repository: struts-site Updated Branches: refs/heads/master a62c7745a -> 62800eb17 Update PlainText result page Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/62800eb1 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/62800eb1 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/62800eb1 Branch: refs/heads/master Commit: 62800eb179b1bf0a0e6b44684fe040282780ab35 Parents: a62c774 Author: Lukasz Lenart Authored: Tue Sep 12 12:27:46 2017 +0200 Committer: Lukasz Lenart Committed: Tue Sep 12 12:27:46 2017 +0200 -- source/core-developers/plaintext-result.md | 35 ++--- 1 file changed, 20 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/62800eb1/source/core-developers/plaintext-result.md -- diff --git a/source/core-developers/plaintext-result.md b/source/core-developers/plaintext-result.md index 74777fe..8bfae9d 100644 --- a/source/core-developers/plaintext-result.md +++ b/source/core-developers/plaintext-result.md @@ -5,24 +5,29 @@ title: PlainText Result # PlainText Result +## Description +A result that send the content out as plain text. Useful typically when needed +to display the raw content of a JSP or Html file for example. -~~~ -{snippet:id=description|javadoc=true|url=org.apache.struts2.dispatcher.PlainTextResult} -~~~ +## Parameters -#Parameters# + - `location` (default) - location of the file (jsp/html) to be displayed as plain text. + - `charSet` (optional) - character set to be used. This character set will be used to set the response type + (eg. `Content-Type=text/plain; charset=UTF-8`) and when reading using a `Reader`. Some example of charSet would be + UTF-8, ISO-8859-1 etc. +## Examples +```xml + + /myJspFile.jsp + -~~~ -{snippet:id=params|javadoc=true|url=org.apache.struts2.dispatcher.PlainTextResult} -~~~ - -#Examples# - - - -~~~ -{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.dispatcher.PlainTextResult} -~~~ + + + /myJspFile.jsp + UTF-8 + + +```
struts-site git commit: Updates production by Jenkins
Repository: struts-site Updated Branches: refs/heads/asf-site 77840af47 -> 0dccbe248 Updates production by Jenkins Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/0dccbe24 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/0dccbe24 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/0dccbe24 Branch: refs/heads/asf-site Commit: 0dccbe2489992b620788bcb5d2cb966cd5d786f2 Parents: 77840af Author: jenkins Authored: Tue Sep 12 10:28:28 2017 + Committer: jenkins Committed: Tue Sep 12 10:28:28 2017 + -- content/core-developers/plaintext-result.html | 33 +++--- 1 file changed, 23 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/0dccbe24/content/core-developers/plaintext-result.html -- diff --git a/content/core-developers/plaintext-result.html b/content/core-developers/plaintext-result.html index 362a738..ff7b772 100644 --- a/content/core-developers/plaintext-result.html +++ b/content/core-developers/plaintext-result.html @@ -127,20 +127,33 @@ https://github.com/apache/struts-site/edit/master/source/core-developers/plaintext-result.md"; title="Edit this page on GitHub">Edit on GitHub PlainText Result -{snippet:id=description|javadoc=true|url=org.apache.struts2.dispatcher.PlainTextResult} - - +Description -#Parameters# +A result that send the content out as plain text. Useful typically when needed +to display the raw content of a JSP or Html file for example. -{snippet:id=params|javadoc=true|url=org.apache.struts2.dispatcher.PlainTextResult} - - +Parameters + + + location (default) - location of the file (jsp/html) to be displayed as plain text. + charSet (optional) - character set to be used. This character set will be used to set the response type +(eg. Content-Type=text/plain; charset=UTF-8) and when reading using a Reader. Some example of charSet would be +UTF-8, ISO-8859-1 etc. + + +Examples -#Examples# ++ -{snippet:id=example|lang=xml|javadoc=true|url=org.apache.struts2.dispatcher.PlainTextResult} - +/myJspFile.jsp ++ ++ /myJspFile.jsp + UTF-8 + +
struts-site git commit: Fixes issue with a list
Repository: struts-site Updated Branches: refs/heads/master 62800eb17 -> dfafd2af5 Fixes issue with a list Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/dfafd2af Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/dfafd2af Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/dfafd2af Branch: refs/heads/master Commit: dfafd2af5748588932a552e51e7d9388f589690b Parents: 62800eb Author: Lukasz Lenart Authored: Tue Sep 12 12:29:34 2017 +0200 Committer: Lukasz Lenart Committed: Tue Sep 12 12:29:34 2017 +0200 -- source/plugins/json/index.md | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/dfafd2af/source/plugins/json/index.md -- diff --git a/source/plugins/json/index.md b/source/plugins/json/index.md index 7586ccf..f63c221 100644 --- a/source/plugins/json/index.md +++ b/source/plugins/json/index.md @@ -151,6 +151,7 @@ the beginning and `wrapPostfix` to add content at the end. This settings take pr and `prefix` which are deprecated from 0.34 on. Examples: - Wrap with comments: + ```xml /* @@ -159,6 +160,7 @@ and `prefix` which are deprecated from 0.34 on. Examples: ``` - Add a prefix: + ```xml {}&& @@ -166,6 +168,7 @@ and `prefix` which are deprecated from 0.34 on. Examples: ``` - Wrap for file upload: + ```xml
struts-site git commit: Updates production by Jenkins
Repository: struts-site Updated Branches: refs/heads/asf-site 0dccbe248 -> 2ec9aaf18 Updates production by Jenkins Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/2ec9aaf1 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/2ec9aaf1 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/2ec9aaf1 Branch: refs/heads/asf-site Commit: 2ec9aaf1882e0c757434e0e22d5c3fbf3876a5a5 Parents: 0dccbe2 Author: jenkins Authored: Tue Sep 12 10:30:09 2017 + Committer: jenkins Committed: Tue Sep 12 10:30:09 2017 + -- content/plugins/json/index.html | 92 1 file changed, 50 insertions(+), 42 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts-site/blob/2ec9aaf1/content/plugins/json/index.html -- diff --git a/content/plugins/json/index.html b/content/plugins/json/index.html index 84274cb..ea58355 100644 --- a/content/plugins/json/index.html +++ b/content/plugins/json/index.html @@ -135,6 +135,7 @@ Including properties Root Object Wrapping + Wrap with Comments Prefix Base Classes Enumerations @@ -341,56 +342,63 @@ the beginning and wrapPostfix to add cont and prefix which are deprecated from 0.34 on. Examples: - Wrap with comments: -```xml + Wrap with comments: - - /* - */ - - -- Add a prefix: -```xml -- {}&& - + ++ /* + */ + + + + + + Add a prefix: + + ++ {}&& + - Wrap for file upload: -```xml + Wrap for file upload: - - - - - -### Wrap with Comments - -`wrapWithComments` is deprecated from 0.34, use `wrapPrefix` and `wrapSuffix` instead. - -> `wrapWithComments` can turn safe JSON text into dangerous text. For example, -> `"\*/ alert('XSS'); /\*"` -> Thanks to Douglas Crockford for the tip! Consider using **prefix** instead. - -If the serialized JSON is `{name: 'El Zorro'}`. Then the output will be: `{}&& ({name: 'El Zorro'})`. - -If the `wrapWithComments` (false by default) attribute is set to true, the generated JSON is wrapped with comments like: - -```json -/* { - "doubleVal": 10.10, - "nestedBean": { - "name": "Mr Bean" - }, - "list": ["A", 10, 20.20, { - "firstName": "El Zorro" - }], - "array": [10, 20] -} */ + ++