SpringMVC 2.5.6 noMapping
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:annotation-config /> <!-- 设置使用注解的类所在的jar包 --> <context:component-scan base-package="com.haier.framework.tms"></context:component-scan> <!-- 完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> <!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/pages/" /> </beans>
/** * */ package com.haier.framework.tms; import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import com.google.gson.Gson; import com.haier.framework.core.utils.CommonJdbcDaoUtils; import com.haier.framework.core.utils.Page; import com.haier.framework.tms.module.TMS_LEG; /** * @author XH * */ @Controller @RequestMapping(value = "/tms/ui/*") public class TmsController { /** * * * @return */ @RequestMapping(value = "index.jhtml", method = RequestMethod.GET) public ModelAndView initEchartsLH(HttpServletRequest request, HttpServletResponse response) { Gson gson = new Gson(); System.out.println("查询=============="); List<TMS_LEG> mm = CommonJdbcDaoUtils.query("select * from TMS_LEG where rownum<20", TMS_LEG.class); System.out.println("query" + gson.toJson(mm)); System.out.println("get=============="); TMS_LEG leg = CommonJdbcDaoUtils.get("select * from TMS_LEG where rownum<20", TMS_LEG.class); System.out.println("get==============" + gson.toJson(leg)); String sysdat = CommonJdbcDaoUtils.queryObject("select sysdate from dual", String.class); System.out.println("QueryObject==============" + sysdat); request.setAttribute("sysdate", sysdat); int start = 0; int limit = 10; Page page = new Page(start, limit, -1, limit, null); CommonJdbcDaoUtils.findBySql(page, "select * from TMS_LEG where rownum<21", "select count(1) from TMS_LEG where rownum<21", TMS_LEG.class); System.out.println("page" + gson.toJson(page)); // return new ModelAndView(new RedirectView("../index.jsp")); // return new ModelAndView("loginSuccess"); // @RequestParam是指请求url地址映射中必须含有的参数(除非属性required=false) // @RequestParam可简写为:@RequestParam("username") // RequestMapping("test/login.do") // 请求url地址映射,类似Struts的action-mapping // public String testLogin(@RequestParam(value="username")String // username, String password, HttpServletRequest request) return new ModelAndView("tms/index.jsp"); } @RequestMapping(value = "getGrid") public void getGrid(HttpServletRequest request, HttpServletResponse response) throws IOException { Gson gson = new Gson(); String json = ""; String start = request.getParameter("start"); String limit = request.getParameter("limit"); Page page = new Page(Integer.parseInt(start), Integer.parseInt(limit), -1, Integer.parseInt(limit), null); CommonJdbcDaoUtils.findBySql(page, "select * from TMS_LEG where rownum<21", "select count(1) from TMS_LEG where rownum<21", TMS_LEG.class); json = gson.toJson(page); System.out.println("page" + json); response.getWriter().write(json); } }
当一个男人什么都没有的时候,他该拿什么说爱呢,