About us

Join us FREE!

how to replace "(double quotes) in a string with \" in java | How do I retrieve query parameters in a Spring Boot controller? | Storing a new object as the value of a hashmap?

Tutorial by Er Satya connectclue-author-image

All > Tech Blogger | Java | Spring Boot | HTML | CSS | MySQL > Java | Spring Boot

1 like

Please login to like this article.

connectclue-linkedin-share

how to replace "(double quotes) in a string with \" in java 

Example - 

str = str.replace("\"", "\\\"")

Avoid using replaceAll since it uses regex syntax in description of what to replace and how to replace, which means that \ will have to be escaped in string "\\" but also in regex \\ (needs to be written as "\\\\" string) which means that we would need to use.
str = str.replaceAll("\"", "\\\\\"");
str = str.replaceAll("\"", Matcher.quoteReplacement("\\\""))

How do I retrieve query parameters in a Spring Boot controller?

Use @RequestParam

@RequestMapping(value="user", method = RequestMethod.GET)
public @ResponseBody Item getItem(@RequestParam("data") String empId){

    Emp i = empDao.findOne(empId);              
String EmpName = i.getEmpName();
String dept= i.getDept(); return i; }



Storing a new object as the value of a hashmap?

HashMap mapper = new HashMap();
mapper.put("Satya", new Emp("Satya"));
... Emp value = mapper.get("Satya"); Integer memory = value.getMemory();


connectclue-linkedin-share

More articles:


Recent lost & found:


Login for enhanced experience

connectclue-tick Create and manage your profile

connectclue-tick Refer an author and get bonus Learn more

connectclue-tick Publish any lost and found belongings

connectclue-tick Connect with the authors & add your review comments

connectclue-tick Join us for Free to advertise for your business or Contact-us for more details

connectclue-tick Join us for Free to publish your own blogs, articles or tutorials and get your Benefits

connectclue-login

Back to top