I want to remove first char from property tag in struts2 ex **<property value="name">** which display name #abhijit but I want to remove first char from that value.
我将字符串附加到操作类中的该特殊字符。 我想将该值作为请求参数传递以获取所有记录 与值匹配。但由于该特殊字符,我没有在操作类中获得值。 这是操作类代码。
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext()
.get(ServletActionContext.HTTP_REQUEST);
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String tagname=request.getParameter("name");
System.out.println("tag to search:"+tagname);
在控制台
搜索标签:
最佳答案
如果你想避免第一个字符,你可以使用 String 子字符串方法并获取字符串值的其余部分,如下所示:
String tagWithoutFirstChar = tagname.subString(1);
或者使用struts setProperty,例如:
<s:property value="tagname.substring(1)" />
关于java - 如何从struts2属性标签中删除字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27728836/