parent
1942cd395a
commit
d6b06dfd04
@ -1,32 +1,51 @@
|
|||||||
package controller;
|
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import domain.yhPO;
|
import domain.yhPO;
|
||||||
import service.yhService;
|
import service.yhService;
|
||||||
@Controller
|
@Controller
|
||||||
public class yhController {
|
public class yhController {
|
||||||
@Autowired@Qualifier("yhServiceImpl")
|
@Autowired@Qualifier("yhServiceImpl")
|
||||||
private yhService yhService;
|
private yhService yhService;
|
||||||
|
@RequestMapping("find2")
|
||||||
@RequestMapping("/search")
|
public void find1(String search,HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
public String search(Model model,String s_id){
|
response.setContentType("text/html;charset=utf-8");
|
||||||
yhPO yhPO=yhService.search(s_id);
|
/* 设置响应头允许ajax跨域访问 */
|
||||||
model.addAttribute("s_id", yhPO.getS_id());
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
model.addAttribute("s_name", yhPO.getS_name());
|
/* 星号表示所有的异域请求都可以接受, */
|
||||||
model.addAttribute("s_password", yhPO.getS_password());
|
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
|
||||||
@RequestMapping("/update")
|
{
|
||||||
public String update(yhPO yhPO){
|
System.out.println("查询失败");
|
||||||
yhService.update(yhPO);
|
Writer out = response.getWriter();
|
||||||
|
out.write("zhaobudao");
|
||||||
|
out.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
<!DOCTYPE web-app PUBLIC
|
<!DOCTYPE web-app PUBLIC
|
||||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
||||||
|
|
||||||
<web-app>
|
<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>
|
</web-app>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue