This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/only-xml-response", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE) | |
@ResponseBody | |
public Object onlyXml(ModelMap modelMap){ | |
//BookDTO 是增加了JAXB注解的一个JavaBean | |
BookDTO b = new BookDTO("Java in Action"); | |
return b; | |
//也可以返回字符串 | |
//return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><book><name>java in action.</name></book>"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.test | |
@Grab("spring-boot-starter-actuator") | |
@RestController | |
public class XmlResponseController { | |
@RequestMapping(value="/xml", method = RequestMethod.GET,produces = MediaType.APPLICATION_XML_VALUE) | |
public def hello() { | |
//实际应用的时候可以用MarkupBuilder来构造 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/download/{filename:.+}", method = RequestMethod.GET) | |
public void download(@PathVariable("filename") String filename,HttpServletRequest request ,HttpServletResponse response){ | |
try { | |
File file=new File(request.getSession().getServletContext().getRealPath("/download/"+filename)); | |
response.setCharacterEncoding("utf-8"); | |
response.setContentType("multipart/form-data"); | |
response.setHeader("Content-Disposition", "attachment;filename="+ filename); | |
response.setHeader("Content-Length", "" + file.length()); | |
//System.out.println(file.getAbsolutePath()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
UpdateConfig that = (UpdateConfig) o; | |
if (!fromVersion.equals(that.fromVersion)) return false; | |
if (!targetVersion.equals(that.targetVersion)) return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
UpdateConfig that = (UpdateConfig) o; | |
return Objects.equal(fromVersion, that.fromVersion) | |
&& Objects.equal(targetVersion, that.targetVersion); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#在%GIT_HOME%\etc\git-completion.bash 这个文件中添加 | |
alias ls='ls --show-control-chars --color=auto' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir myprj | |
cd myprj | |
git init | |
touch README.md | |
git add README.md | |
git commit -m "first commit" | |
git remote add origin https://git.oschina.net/yourname/myprj.git | |
git push -u origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String json = Resources.toString(Resources.getResource("com/mycompany/test/fixture/config_fixture.json"), Charsets.UTF_8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- H2的混合模式 --> | |
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> | |
<property name="driverClassName" value="org.h2.Driver" /> | |
<!--<property name="url" value="jdbc:h2:~/databases/mydb" />--> | |
<property name="url" value="jdbc:h2:file://D:\h2\mydb;AUTO_SERVER=TRUE;USER=SA;" /> | |
</bean> | |
<!-- H2的内存模式 --> | |
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#-- | |
* 结合bootstrap的样式,有错误的时候高亮显示字段 | |
* config是表单绑定的模型对象,targetVersion是它的一个属性 | |
--> | |
<@spring.bind "config.targetVersion"/> | |
<#assign error> | |
<#if spring.status.errorMessages?has_content>error</#if> | |
</#assign> | |
<div class="control-group ${error}"> | |
<label class="control-label" for="inputTargetVersion">升级后版本</label> |
OlderNewer