1 changed files with 46 additions and 0 deletions
@ -0,0 +1,46 @@ |
|||||||
|
package demo.liaofeifei; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@RestController |
||||||
|
public class ins { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private JdbcTemplate jdbcTemplate; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/ins") |
||||||
|
public String getAllNewTableData_ins(HttpServletRequest request) { |
||||||
|
|
||||||
|
String ins_id = request.getParameter("ins_id");//获取机构号
|
||||||
|
|
||||||
|
String sql = "select * from ins where ins_id ='" + ins_id + "'";//编辑查询数据库语句
|
||||||
|
String result=""; |
||||||
|
|
||||||
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);//数据库语句执行
|
||||||
|
|
||||||
|
|
||||||
|
if(list.size() > 0)//判断上面sql语句的查询结果,是否存在(数据库是否存在有与浏览器输入的ID一样的结果,有则list1.size()大于0)
|
||||||
|
{ |
||||||
|
result=list.toString();//结果存在返回查询结果
|
||||||
|
} |
||||||
|
else { |
||||||
|
result="0";//不存在输出0
|
||||||
|
System.out.println("测试:" + list.toString());//获取执行结果
|
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue