ssm(6))spring-test
Posted 白日梦
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssm(6))spring-test相关的知识,希望对你有一定的参考价值。
@RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration//注解该注解之后才能获取@Autowired的context @ContextConfiguration({"classpath:application.xml","classpath:springmvc.xml"}) public class SpringTestContorllerTest { @Autowired WebApplicationContext context; MockMvc mockMvc; @Before public void initMockMvc(){ mockMvc= MockMvcBuilders.webAppContextSetup(context).build(); } @Test public void testLogin() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/modelAttribute").param("pwd", "123") .param("pwd", "123456")).andReturn(); MockHttpServletRequest request = mvcResult.getRequest(); MockHttpServletResponse response = mvcResult.getResponse(); } }
待续:spring -test
以上是关于ssm(6))spring-test的主要内容,如果未能解决你的问题,请参考以下文章
SSM-MyBatis-05:Mybatis中别名,sql片段和模糊查询加getMapper