j 2 eeのajax
- <td>
- :
- </td>
- <td>
- <input type="text" name="loginname" id="loginname" onblur="javascript:clickButton()"/>
-
- <font color="red">*</font>
-
- </td>
- <td id="tes" style="color:red" ></td>
-
- <SCRIPT type="text/javascript">
-
- function clickButton()
-
- {
- var url = 'jaaction';
- var params = {
- name:$('#loginname').attr('value') //attr('value')
- };
- jQuery.post(url, params, callbackFun, 'json');
- }
-
- function callbackFun(data)
-
- {
- $('#tes').html(data.result) //html
- // HelloWorld message
- //
- }
-
-
-
-
-
- document.write("<h1>hello world</h1>"); </script>
- package com.action.user;
-
-
-
- import java.util.List;
-
- import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
-
- import com.dao.userdao.IUserinfoDAO;
- import com.dao.userdao.Userinfo;
- import com.opensymphony.xwork2.ActionSupport;
-
-
- public class JaAction extends ActionSupport {
- private String name;
- private String result;
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String getResult() {
- return result;
- }
-
- public void setResult(String result) {
- this.result = result;
- }
- @Override
- public String execute() throws Exception {
- ApplicationContext ctx = new ClassPathXmlApplicationContext(
- "applicationContext.xml");
- IUserinfoDAO dao = (IUserinfoDAO) ctx.getBean("UserinfoDAO");
-
- if (!dao.findByLoginname(this.name).isEmpty()) {
- System.out.println("lj");
- setResult(" ");
- return SUCCESS;
- } else {
- System.out.println("llj");
- setResult(" ");
- return SUCCESS;
- }
- }
- }