Spring 4 MVC ContentNegotiatingViewResolver example

This article demonstrates supporting multiple output formats for your Spring 4 MVC application using Spring’sContentNegotiatingViewResolver. We will be generating application output in XML, JSON, PDF, XLS and HTML format, all using Annotation based configuration. ContentNegotiatingViewResolver is an implementation of ViewResolver, which uses the requested media type (based on filetype extension, URL parameter specifying type of…

google spreadsheet api json xml html

It is not that straight forward to get the xml/json/html outpt for  a google spreadsheet.    HTML First thing we need to do is to publish the sheet under File -> publish to the web…. Here is what you may gethttps://docs.google.com/spreadsheets/d/YOUR-SHEET_ID/pubhtml Now you have the html version.  XML/JSON  After you get the shee-id, what you…

how Spring finds applicationContext xml

Spring can be easily integrated into any Java-based web framework. All you need to do is to declare the ContextLoaderListener in your web.xml and use a contextConfigLocation <context-param> to set which context files to load. The <context-param>: <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext*.xml</param-value> </context-param> The <listener>: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> NOTE: Listeners were added to the Servlet API in version 2.3. If you have a Servlet…

java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImpl cannot be cast to org.w3c.dom.Element

However, after I copy this into IDE and use: Element metadataElement = (Element) rootNode.getFirstChild(); I am getting: java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImpl cannot be cast to org.w3c.dom.Element It turns out : The first child is the whitespace between the end of submission and the start of submissionMetadata. Using w3c DOM to walk the tree is not so easy….

use variable in xslt

Variables we can define global variable at the beginning: TO use the variable just use: $ not AND concat use not() in the xls:if for negative: <xsl:if test=”not(./dataValueGrid[@name=reviewHistoryList])”>….</xls:if> use concat() for string concat, use “,” to seperate: <xsl:value-of select=”concat(‘/Application/DirectFormAccess.jsp?requestInstance=’, $reviewInstanceIdVar)” />

xslt apply templates

When you use <xsl:apply-templates/>, it is really short for <xsl:apply-templates select=”node()”/> and is being invoked inside of a template match on /, which is the root node of the document and an abstract concept for the top of the file. It’s children include the document element (i.e. <Page>), as well as any top-level comments or processing instructions that may be…

add CDATA to xml DOM tree

A CDATA section indicates a block that shouldn’t be parsed. To build a CDATA section just wrap the string with a CDATA object. If append TextNode directly, it will not appear as CDATA but just plain text.

xml parse line break, line feed lost

\n or line break or line feed in a string would be stripped by xml parser and replaced by space. According to XML specification, any white space will be normalized into #xA; In order to preserve the line feed, we can just replace all the \n with which is the legal line feed in…

Notepad++ format xml file (indent)

TextFX To Indent a XML file in notepad++, TextFX > TextFX HTML Tidy > Tidy Reindent XML If the TextFX menu does not exist, you need to download & install the plugin. Plugins->Plugin Manager->Show Plugin Manager and then check the plugin TextFX Characters. Click ‘install,’ restart Notepad++. libTidy.dll might not be included in the new version of NPP. Solution…

create a quick android app with rss

现在很多的网站都推出了自己的app,但是对于我们这些普通的小网站来说,自己去做一个app有点得不尝试,也没有去那么的精力去做这些,于是就有人做了这样的服务,AppYet就是这样的而一个服务,只要提供网站的feed rss地址,appyet就能自动的生成一个比较perfect的app,只是对于免费的用户, 嵌套了广告,毕竟是免费的,我们也就没有什么可以说的。 appyet是提供了一种服务,只需你提供网站的feed rss,就能很快的生成一个网站的app出来,对于小网站用户来说足矣。(from this blog) 对于webvanta, 提供了rss生成script rss2.0的格式: <?xml version=”1.0″ encoding=”UTF-8″?> <rss version=”2.0″> <channel>     <title>DotNetBips.com Latest Articles</title>     <link>www.dotnetbips.com</link>     <description>DotNetBips.com Latest Articles</description>     <language>zh-cn</language>     <copyright>Copyright (C) DotNetBips.com. All rights reserved.</copyright>     <generator>www.dotnetbips.com RSS Generator</generator>     <item>     <title>Using WebRequest and WebResponse</title>     <link>http://www.dotnetbips.com/displayarticle.aspx?id=239</link&gt;     <description>Description here</description>     <category></category>     <author>Bipin Joshi</author>     <copyright></copyright>     <pubDate>Sun, 25 Jan 2004 12:00:00 AM GMT</pubDate>     </item> </channel> </rss> rss:  每个RSS Feed,都有而且只能有一个rss标签,作为顶层元素,属性version是版本号,如2.0 channel:   在rss标签下,必须有且只能有一个channel标签,可包含