2015-01-01 54 views
0
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. 

我在字符串中添加了该字符串。 我想要传递该值作为请求参数,以获得所有与 匹配的记录。但由于该特殊字符,我不在动作类中创建值。 这里是动作类代码。如何从struts2属性标签中删除字符

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); 

在控制台

标签搜索:

+0

http:// localhost:8080/project/result?name =#newone –

回答

1

如果你想避免的第一个字符,你可以使用字符串的子串的方法和获取字符串值的其余部分象下面这样:

String tagWithoutFirstChar = tagname.subString(1); 

或者使用struts的SetProperty喜欢:

<s:property value="tagname.substring(1)" /> 
+0

感谢它的运作。 –