2015-01-01 53 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

感謝它的運作。 –