parent
1942cd395a
commit
d6b06dfd04
@ -1,32 +1,51 @@
|
||||
package controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import domain.yhPO;
|
||||
import service.yhService;
|
||||
@Controller
|
||||
public class yhController {
|
||||
@Autowired@Qualifier("yhServiceImpl")
|
||||
private yhService yhService;
|
||||
|
||||
@RequestMapping("/search")
|
||||
public String search(Model model,String s_id){
|
||||
yhPO yhPO=yhService.search(s_id);
|
||||
model.addAttribute("s_id", yhPO.getS_id());
|
||||
model.addAttribute("s_name", yhPO.getS_name());
|
||||
model.addAttribute("s_password", yhPO.getS_password());
|
||||
@RequestMapping("find2")
|
||||
public void find1(String search,HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
/* 设置响应头允许ajax跨域访问 */
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
/* 星号表示所有的异域请求都可以接受, */
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
|
||||
yhPO yhPO=this.yhService.FindBysname(search);
|
||||
if(yhPO!=null) {
|
||||
String ss = new Gson().toJson(yhPO);
|
||||
System.out.println(ss);
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.print(ss);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("查询失败");
|
||||
Writer out = response.getWriter();
|
||||
out.write("zhaobudao");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public String update(yhPO yhPO){
|
||||
yhService.update(yhPO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,20 @@
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||
|
||||
<web-app>
|
||||
<display-name>Archetype Created Web Application</display-name>
|
||||
<display-name>Archetype Created Web Application</display-name>
|
||||
<!-- Processes application requests -->
|
||||
<servlet>
|
||||
<servlet-name>appServlet</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>classpath:spring-*.xml</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>appServlet</servlet-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue