本文整理汇总了Java中org.springframework.web.servlet.view.xml.MarshallingView类的典型用法代码示例。如果您正苦于以下问题:Java MarshallingView类的具体用法?Java MarshallingView怎么用?Java MarshallingView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MarshallingView类属于org.springframework.web.servlet.view.xml包,在下文中一共展示了MarshallingView类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resolveViewName
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Override
public View resolveViewName(String viewName, Locale locale)
throws Exception {
MarshallingView view = new MarshallingView();
view.setMarshaller(marshaller);
//view.setModelKey("products");
return view;
}
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:9,代码来源:CustomXMLViewResolver.java
示例2: contentNegotiationAddsDefaultViewRegistrations
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Test
public void contentNegotiationAddsDefaultViewRegistrations() {
MappingJackson2JsonView view1 = new MappingJackson2JsonView();
this.registry.enableContentNegotiation(view1);
ContentNegotiatingViewResolver resolver1 = checkAndGetResolver(ContentNegotiatingViewResolver.class);
assertEquals(Arrays.asList(view1), resolver1.getDefaultViews());
MarshallingView view2 = new MarshallingView();
this.registry.enableContentNegotiation(view2);
ContentNegotiatingViewResolver resolver2 = checkAndGetResolver(ContentNegotiatingViewResolver.class);
assertEquals(Arrays.asList(view1, view2), resolver2.getDefaultViews());
assertSame(resolver1, resolver2);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ViewResolverRegistryTests.java
示例3: testXmlOnly
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Test
public void testXmlOnly() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(Person.class);
standaloneSetup(new PersonController()).setSingleView(new MarshallingView(marshaller)).build()
.perform(get("/person/Corea"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_XML))
.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:ViewResolutionTests.java
示例4: testContentNegotiation
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Test
public void testContentNegotiation() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(Person.class);
List<View> viewList = new ArrayList<View>();
viewList.add(new MappingJackson2JsonView());
viewList.add(new MarshallingView(marshaller));
ContentNegotiationManager manager = new ContentNegotiationManager(
new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));
ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
cnViewResolver.setDefaultViews(viewList);
cnViewResolver.setContentNegotiationManager(manager);
cnViewResolver.afterPropertiesSet();
MockMvc mockMvc =
standaloneSetup(new PersonController())
.setViewResolvers(cnViewResolver, new InternalResourceViewResolver())
.build();
mockMvc.perform(get("/person/Corea"))
.andExpect(status().isOk())
.andExpect(model().size(1))
.andExpect(model().attributeExists("person"))
.andExpect(forwardedUrl("person/show"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.person.name").value("Corea"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_XML))
.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:ViewResolutionTests.java
示例5: testContentNegotiation
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Test
public void testContentNegotiation() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(Person.class);
List<View> viewList = new ArrayList<View>();
viewList.add(new MappingJacksonJsonView());
viewList.add(new MarshallingView(marshaller));
ContentNegotiationManager manager = new ContentNegotiationManager(
new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));
ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
cnViewResolver.setDefaultViews(viewList);
cnViewResolver.setContentNegotiationManager(manager);
cnViewResolver.afterPropertiesSet();
MockMvc mockMvc =
standaloneSetup(new PersonController())
.setViewResolvers(cnViewResolver, new InternalResourceViewResolver())
.build();
mockMvc.perform(get("/person/Corea"))
.andExpect(status().isOk())
.andExpect(model().size(1))
.andExpect(model().attributeExists("person"))
.andExpect(forwardedUrl("person/show"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.person.name").value("Corea"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_XML))
.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:40,代码来源:ViewResolutionTests.java
示例6: marshallingView
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Bean(name = "vets/vetList.xml")
@Description("Renders an XML view. Used by the BeanNameViewResolver")
public MarshallingView marshallingView() {
return new MarshallingView(marshaller());
}
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:6,代码来源:MvcViewConfig.java
示例7: resolveViewName
import org.springframework.web.servlet.view.xml.MarshallingView; //导入依赖的package包/类
@Override
public View resolveViewName(String viewName, Locale locale) throws Exception {
MarshallingView marshallingView = new MarshallingView();
marshallingView.setMarshaller(marshaller);
return marshallingView;
}
开发者ID:arnaldop,项目名称:enhanced-pet-clinic,代码行数:7,代码来源:XmlViewResolver.java
注:本文中的org.springframework.web.servlet.view.xml.MarshallingView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论