JavaScript Java JSP
java 后台传回一个变量 String型的变量 player_name --> "-晴空" " ,传到前台在javascript中用encodeURIComponent( “${item.thread.playerName}”);会错误 在jsp总怎么将后台的变量转义。。
求高人指点
回复讨论(解决方案)
encodeURIComponent('${item.thread.playerName}');
或者在java里面把
playerName替换成playerName=playerName.replace("\"","\\\"")
因为在 后台该数据我还没找到。。。
所以想在前台 改变 有啥办法吗?
这几个字符应该不会歧义,前端输出是什么?是否编码问题?
encodeURIComponent("${item.thread.playerName}");
是对 ${item.thread.playerName} 这个 串做 url 编码
而不是对 ${item.thread.playerName} 的 值做 url 编码
如果服务器端做了转义,你也只能做逆转义
再做转义肯定是不对的
就是因为服务器 端没有转义 , 在前端把它的值提出来 转义行吗?
哎 后面发现

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor
