Home  >  Article  >  Web Front-end  >  EL expression in JS to obtain related element parameters

EL expression in JS to obtain related element parameters

php中世界最好的语言
php中世界最好的语言Original
2018-05-03 09:58:101587browse

This time I will bring you the EL expression in JS to obtain the relevant element parameters. What are the precautions for the EL expression in JS to obtain the relevant element parameters. The following is a practical case. , let’s take a look.

1. actionReturn parameters to the page

/**
 * 测试js中获取后台传值
 * @param model
 * @param req
 * @return	String
 */
@RequestMapping("getValue")
public String getValue(Model model, HttpServletRequest req){
	model.addAttribute("stringValue", "测试在js中取值...");
	model.addAttribute("numberValue", 111);
	List list = new ArrayList();
	list.add("aaa");
	list.add("bbb");
	list.add("ccc");
	model.addAttribute("arrayValue", list);
	model.addAttribute("jsonStringValue", JSON.toJSONString(list));
	User user = new User();
	user.setUserID("1");
	user.setUserName("test");
	user.setMobile("13800000000");
	user.setEmail("test@163.com");
	user.setNickName("test");
	model.addAttribute("objJsonString", JSON.toJSONString(user));
	return "/getValue.htm";
}

2. Use EL in js Expression to get the parameter value

Note: takes the numeric parameter value, and the EL expression in js does not need to be quoted; take String parameter values, EL expressions in js need to be quoted; object and collection type parameter values ​​need to be converted using JSON.toJSONString() in the background.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How the front-end transmits Json data to the background

Koa2 makes file upload and download functions

The above is the detailed content of EL expression in JS to obtain related element parameters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn