spring mvc

来源:互联网 发布:网络盒子什么牌子好 编辑:程序博客网 时间:2024/06/15 15:17

params(多个方法重载)

exception 出来

文件上传(配置resolver)

资源文件(mvc:resouces)

<form:form>, model attribute

model

@pathvarible  @requestParm @validated @responseBody @requestMapping


spring 4

@RestController

It’s shorthand for @Controller and @ResponseBody rolled together


@ComponentScan@EnableAutoConfigurationpublic class Application {    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }}


RestTemplate restTemplate = new RestTemplate();        Page page = restTemplate.getForObject("http://graph.facebook.com/gopivotal", Page.class);        System.out.println("Name:    " + page.getName());        System.out.println("About:   " + page.getAbout());        System.out.println("Phone:   " + page.getPhone());        System.out.println("Website: " + page.getWebsite());
mvn clean package && java -jar target/gs-consuming-rest-0.1.0.jar

or


With mvn, you can run mvn spring-boot:run.



thymeleaf与spring整合

1、使用的是Spring EL而不是Ognl。
2、访问上下文的Bean用${@myBean.doSomething()}
3、th:field,th:errors,th:errorclass用于form processing。
4、要采用SpringTemplateEngine。
5、基本配置:

<bean id="templateResolver"
       class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
  <property name="prefix" value="/WEB-INF/templates/" />
  <property name="suffix" value=".html" />
  <property name="templateMode" value="HTML5" />
</bean>
    
<bean id="templateEngine"
      class="org.thymeleaf.spring3.SpringTemplateEngine">
  <property name="templateResolver" ref="templateResolver" />
</bean>

<bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
  <property name="templateEngine" ref="templateEngine" />
  <property name="order" value="1" />
  <property name="viewNames" value="*.html,*.xhtml" />
</bean>

http://www.blogjava.net/bjwulin/archive/2014/02/11/409734.html

http://www.thymeleaf.org/doc/html/Using-Thymeleaf.html


mockito+MockMvc 测试

0 0
原创粉丝点击