我一直试图解析json对象的特定部分。更具体地说,我提取http://www.dprobuk.com/api/get_post?id=677&include=title,id,content这是一个JSON数组,并且我已经提取了"内容"键。所以对我来说真正的问题现在在内容键中,有一个textarea标签,其内容我想将它存储在字符串中。但是这样做我得到了非法的转义序列错误。
实施例: String st =" http:\ / \ / www.dprobuk.com/"所以它自然是非法的,是否有一些其他方式在java中存储上面的字符串?或者从上面的JSON数组中分割textarea的其他方法吗?
<div id="my"></div><script>
var st="<textarea wrap=\"soft\" class=\"crayon-plain print-no\" data-settings=\"dblclick\" readonly style=\"-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;\">"+
"\n<html>\r\n <head>\r\n <title>HTML Form using Bootstrap<\/title>\r\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> \r\n <link href=\"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.5\/css\/bootstrap.min.css\" rel=\"stylesheet\">\r\n <script src=\"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.5\/js\/bootstrap.min.js\" type=\"text\/javascript\"><\/script>\r\n <\/head>\r\n <body style=\"background:url(pattern1.jpg);\"> \r\n <div class=\"container\">\r\n <div class=\"row\">\r\n <div class=\"col-lg-8 col-lg-offset-2\">\r\n <h1>This is a Sample Form Using BootStrap<\/h1>\r\n <br\/><br\/>\r\n <form name=\"sentMessage\" id=\"contactForm\" novalidate>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Name<\/label>\r\n <input type=\"text\" class=\"form-control\" placeholder=\"Name\" id=\"name\" required data-validation-required-message=\"Please enter your name.\">\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Email Address<\/label>\r\n <input type=\"email\" class=\"form-control\" placeholder=\"Email Address\" id=\"email\" required data-validation-required-message=\"Please enter your email address.\">\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Phone Number<\/label>\r\n <input type=\"tel\" class=\"form-control\" placeholder=\"Phone Number\" id=\"phone\" required data-validation-required-message=\"Please enter your phone number.\">\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Message<\/label>\r\n <textarea rows=\"5\" class=\"form-control\" placeholder=\"Message\" id=\"message\" required data-validation-required-message=\"Please enter a message.\"><\/textarea>\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <br>\r\n <div class=\"row\">\r\n <div class=\"form-group col-xs-12\">\r\n <button type=\"submit\" class=\"btn btn-success btn-lg\">Send<\/button>\r\n <\/div>\r\n <\/div>\r\n <\/form>\r\n <\/div>\r\n <\/div>\r\n <\/div>\r\n <\/body>\r\n<\/html>"+
"<\/textarea>";
var ta = document.getElementById('my');
ta.innerHTML=st;</script>
上面的代码有效,但是当我在Java中使用相同的变量st作为字符串时,它无法编译!
class SimpleCode
{
public static void main(String []as)
{
String st="<textarea wrap=\"soft\" class=\"crayon-plain print-no\" data-settings=\"dblclick\" readonly style=\"-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;\">"+
"\n<html>\r\n <head>\r\n <title>HTML Form using Bootstrap<\/title>\r\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> \r\n <link href=\"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.5\/css\/bootstrap.min.css\" rel=\"stylesheet\">\r\n <script src=\"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.5\/js\/bootstrap.min.js\" type=\"text\/javascript\"><\/script>\r\n <\/head>\r\n <body style=\"background:url(pattern1.jpg);\"> \r\n <div class=\"container\">\r\n <div class=\"row\">\r\n <div class=\"col-lg-8 col-lg-offset-2\">\r\n <h1>This is a Sample Form Using BootStrap<\/h1>\r\n <br\/><br\/>\r\n <form name=\"sentMessage\" id=\"contactForm\" novalidate>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Name<\/label>\r\n <input type=\"text\" class=\"form-control\" placeholder=\"Name\" id=\"name\" required data-validation-required-message=\"Please enter your name.\">\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Email Address<\/label>\r\n <input type=\"email\" class=\"form-control\" placeholder=\"Email Address\" id=\"email\" required data-validation-required-message=\"Please enter your email address.\">\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Phone Number<\/label>\r\n <input type=\"tel\" class=\"form-control\" placeholder=\"Phone Number\" id=\"phone\" required data-validation-required-message=\"Please enter your phone number.\">\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <div class=\"row control-group\">\r\n <div class=\"form-group col-xs-12 floating-label-form-group controls\">\r\n <label>Message<\/label>\r\n <textarea rows=\"5\" class=\"form-control\" placeholder=\"Message\" id=\"message\" required data-validation-required-message=\"Please enter a message.\"><\/textarea>\r\n <p class=\"help-block text-danger\"><\/p>\r\n <\/div>\r\n <\/div>\r\n <br>\r\n <div class=\"row\">\r\n <div class=\"form-group col-xs-12\">\r\n <button type=\"submit\" class=\"btn btn-success btn-lg\">Send<\/button>\r\n <\/div>\r\n <\/div>\r\n <\/form>\r\n <\/div>\r\n <\/div>\r\n <\/div>\r\n <\/body>\r\n<\/html>"+
"<\/textarea>";
System.out.println(st);
}
}
所以我想知道任何其他程序让它起作用吗?
答案 0 :(得分:1)
pom.xml