我正在使用Woocommerce在我的Wordpress网站上销售数字下载.我已经能够使用插件来自定义结帐页面,这样客户只需提供他们的姓名和电子邮件地址即可购买产品.我希望在" 客户信息"页面和" 编辑我的地址"页面和" 帐户"页面上显示相同的内容.
现在位于帐户页面的底部,它是从my-address.php页面调用信息.它会显示结算地址(姓名和送货地址),但不会显示,因为他们没有被要求输入送货地址.
我希望结算地址为"姓名",发货地址为"电子邮件",并且可以从中调用此人的电子邮件地址my-address.php.我实际上知道如何将帐单地址更改为名称.但我无法弄清楚如何将发货地址更改为电子邮件并显示此人的电子邮件.
有谁知道我怎么能做到这一点?
谢谢你的时间.
我想检查模式匹配,如果模式匹配,那么我想将这些文本匹配替换为测试数组中给定索引处的元素。
public class test {
public static void main(String[] args) {
String[] test={"one","two","three","four"}
Pattern pattern = Pattern.compile("\\$(\\d)+");
String text="{\"test1\":\"$1\",\"test2\":\"$5\",\"test3\":\"$3\",\"test4\":\"$4\"}";
Matcher matcher = pattern.matcher(text);
while(matcher.find()) {
System.out.println(matcher.groupCount());
System.out.println(matcher.replaceAll("test"));
}
System.out.println(text);
}
}
Run Code Online (Sandbox Code Playgroud)
我希望最终结果文本字符串采用以下格式:
{\"test1\":\"one\",\"test2\":\"$two\",\"test3\":\"three\",\"test4\":\"four\"}
Run Code Online (Sandbox Code Playgroud)
但 while 循环在一场比赛后退出,并"test"在各处被替换,如下所示:
{"test1":"test","test2":"test","test3":"test","test4":"test"}
Run Code Online (Sandbox Code Playgroud)
使用下面的代码我得到了结果:
public class test {
public static void main(String[] args) {
String[] test={"one","two","three","four"};
Pattern pattern = Pattern.compile("\\$(\\d)+");
String text="{\"test1\":\"$1\",\"test2\":\"$2\",\"test3\":\"$3\",\"test4\":\"$4\"}";
Matcher m = pattern.matcher(text);
StringBuffer sb = new StringBuffer();
while (m.find()) {
m.appendReplacement(sb, test[Integer.parseInt(m.group(1)) - 1]);
}
m.appendTail(sb);
System.out.println(sb.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我有一个像这样的替换文本数组, …
这是我使用Spring Framework的Java代码:
@RequestMapping(method = RequestMethod.POST)
public @ResponseBody String SampleFunction(@RequestHeader("Authorization") String details)
{
System.out.println("Authorization details recieved");
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试访问Authorization标题.我想Authorization通过将它重定向到400 Bad Request页面来处理丢失的标题.我怎样才能做到这一点?