(待补全测试结果)crm小问题注意:add.jsp添加客户页面回显字典供选择。【查询字典时传参数typeCode不能和属性名相同】

===============

====struts接受参数。参数名不能和 字典类的 类型码 属性dictTypeCode同名。否则接收参数失败。原因不详。===注意。

====【是不是查询所有的实体类信息,查询条件 参数,都不能 和实体类属性名相同?待测。】


========================

add.jsp   ajax代码。===回显字典供选择。查询某一类型字典时传参数typeCode

<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<TITLE>添加客户</TITLE> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="${pageContext.request.contextPath }/css/Style.css" type=text/css rel=stylesheet>
<LINK href="${pageContext.request.contextPath }/css/Manage.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.3492" name=GENERATOR>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
// 页面加载函数|匿名函数
 $(function(){
// 	 行业
	 $.post("${pageContext.request.contextPath }/customerAction_findBaseDictByTypeCode.action",{"typeCode":"001"},function(data){
		 for (var i = 0; i < data.length; i++) {
			 $("#custIndustry").append("<option value='"+data[i].dictId+"'>"+data[i].dictName+"</option>");
		 }
		 $("#custIndustry option[value=${customer.custIndustry.dictId}]").attr("selected","selected");
	 },"json");
// 	 ${customer.custIndustry.dictId} 2
	 
	 
// 	 来源
	 $.post("${pageContext.request.contextPath }/customerAction_findBaseDictByTypeCode.action",{"typeCode":"002"},function(data){
		 for (var i = 0; i < data.length; i++) {
			 $("#custSource").append("<option value='"+data[i].dictId+"'>"+data[i].dictName+"</option>");
		}
		 $("#custSource option[value=${customer.custSource.dictId}]").attr("selected","selected");
	 },"json");
	 
// 	 等级
	 $.post("${pageContext.request.contextPath }/customerAction_findBaseDictByTypeCode.action",{"typeCode":"006"},function(data){
		 for (var i = 0; i < data.length; i++) {
			 $("#custLevel").append("<option value='"+data[i].dictId+"'>"+data[i].dictName+"</option>");
		}
		 $("#custLevel option[value=${customer.custLevel.dictId}]").attr("selected","selected");
	 },"json");
	 
 })

</script>
</HEAD>


=======

customerAction:

@Controller
@Scope("prototype")
@ParentPackage("struts-default")
@Namespace("/")
public class CustomerAction extends ActionSupport implements ModelDriven<Customer>{
	@Autowired
	private  CustomerService cs;  
	
	@Action(value="customerAction_toadd",results={@Result(name="success",location="/jsp/customer/add.jsp")})
	public String toadd() {
		return "success";
	}
	
	
	String typeCode;//====struts接受参数。参数名不能和 字典类的类型码 属性dictTypeCode同名。否则接收参数失败。原因不详。===注意。
	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}
	@Action(value="customerAction_findBaseDictByTypeCode")
	public void findBaseDictByTypeCode() {
		//System.out.println("typeCode:"+typeCode);
		List<BaseDict> dicts = cs.findBaseDictByTypeCode(typeCode);
		String json = JSON.toJSON(dicts).toString();
		
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("application/json;charset=utf-8");
		//System.out.println(json);
		try {
			response.getWriter().write(json);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

字典类:

@Entity
@Table(name="base_dict")
public class BaseDict {
 

	@Id
	@Column(name="dict_id") 
	private String dictId;
	
	
	@Column(name="dict_name")
	private String dictName;
	
	
	@Column(name="dict_type_code")
	private String dictTypeCode;//=====这里
	


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值