1. JUnit 单元测试时, 测试类必须写在platform工程下的相应目录,且必须在test相同目录下有相同的映射文件。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath*:spring/applicationContext.xml"})
public class FincTest {
@Autowired
private IRechargeService rechargeService;
@Before
public void setUp()
throws Exception {
}
@After
public void tearDown()
throws Exception {
}
/**
*
* @Description: TODO(测试线下充值查询列表)
* @author:刘被华
* @date:2015年10月12日 下午5:27:48
* @throws Exception
*/
@Test
public void findOfflineRechargeList()
throws Exception {
BusRechargeOfflineForListReq req = new BusRechargeOfflineForListReq();
req.setRecUserName("张三");
rechargeService.findOfflineRechargeList(req);
}
}
2. 项目启动报错,接口调用会有问题。
3. JSP页面中使用 Conroller中定义的ModelAndView 数据
@RequestMapping(value = "/articleGuide.do", method = RequestMethod.GET, produces = {"application/json",
"application/xml"})
public ModelAndView getArticleGuide(FindArticleGuideReq findReq, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
String typeName = request.getParameter("typeName");
int type = Integer.parseInt(typeName);
String linkUrl = "";
// 4关于我们、5联系我们'
if (type == 4)
{
linkUrl = "home/aboutUs.page";
}
else if (type == 5)
{
linkUrl = "home/contactUs.page";
}
ModelAndView mv = new ModelAndView(linkUrl);
TSiteArticleInfoReq tfindReq = new TSiteArticleInfoReq();
tfindReq.setTypeName(findReq.getTypeName());
String data = new CommonUtil().callInterfaceMethod(tfindReq, "site/articleInfo/articleGuide", RequestMethod.GET, request);
if(StringUtils.isNotBlank(data)){
JSONObject jsonArray = (JSONObject)CommonUtil.getJSONObject(data, null);
mv.addObject("articleInfo",jsonArray);
}
return mv;
}
jsp页面中:
<div>
<p>${articleInfo.content}</p>
</div>
4. 通过链接或 浏览器中输入路径(http://localhost:8080/article/aboutus/articleGuide.do?typeName=5)访问Controller中的方法:
@Controller
@RequestMapping(value = "article/aboutus")
public class ArticleGuideController extends BaseController
{
@RequestMapping(value = "/articleGuide.do", method = RequestMethod.GET, produces = {"application/json",
"application/xml"})
public ModelAndView getArticleGuide(FindArticleGuideReq findReq, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
}
}
}