SSH 常见权限设计四:如何得到<s:a action="url">kkk</s:a>里面的url
2016-10-07 08:49
399 查看
一、如图:
二、修改原码:
修改doEndTag函数里的内容
二、修改原码:
修改doEndTag函数里的内容
/* * $Id: AnchorTag.java 768855 2009-04-27 02:09:35Z wesw $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.struts2.views.jsp.ui; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspException; import org.apache.struts2.components.Anchor; import org.apache.struts2.components.Component; import cn.oppo.oa.domain.User; import com.opensymphony.xwork2.util.ValueStack; /** * @see Anchor */ public class AnchorTag extends AbstractClosingTag { private static final long serialVersionUID = -1034616578492431113L; protected String href; protected String includeParams; protected String scheme; protected String action; protected String namespace; protected String method; protected String encode; protected String includeContext; protected String escapeAmp; protected String portletMode; protected String windowState; protected String portletUrlType; protected String anchor; protected String forceAddSchemeHostAndPort; @Override public int doEndTag() throws JspException { // 当前用户 User user = (User) pageContext.getSession().getAttribute("user"); // 当前的URL,如果有参数就要去掉后面的参数字符串 String privilegeUrl = action; int pos = privilegeUrl.indexOf("?"); if (pos > -1) { privilegeUrl = privilegeUrl.substring(0, pos); } if (user.hasPrivilegeByUrl(privilegeUrl)) { return super.doEndTag(); // 如果有权限,就正常的生成与输出<a>标签 } else { return EVAL_PAGE; // 如果没有权限,就不显示当前<a>标签,只是继续执行页面中后面的代码 } } public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) { return new Anchor(stack, req, res); } protected void populateParams() { super.populateParams(); Anchor tag = (Anchor) component; tag.setHref(href); tag.setIncludeParams(includeParams); tag.setScheme(scheme); tag.setValue(value); tag.setMethod(method); tag.setNamespace(namespace); tag.setAction(action); tag.setPortletMode(portletMode); tag.setPortletUrlType(portletUrlType); tag.setWindowState(windowState); tag.setAnchor(anchor); if (encode != null) { tag.setEncode(Boolean.valueOf(encode).booleanValue()); } if (includeContext != null) { tag.setIncludeContext(Boolean.valueOf(includeContext).booleanValue()); } if (escapeAmp != null) { tag.setEscapeAmp(Boolean.valueOf(escapeAmp).booleanValue()); } if (forceAddSchemeHostAndPort != null) { tag.setForceAddSchemeHostAndPort(Boolean.valueOf(forceAddSchemeHostAndPort).booleanValue()); } } public void setHref(String href) { this.href = href; } public void setEncode(String encode) { this.encode = encode; } public void setIncludeContext(String includeContext) { this.includeContext = includeContext; } public void setEscapeAmp(String escapeAmp) { this.escapeAmp = escapeAmp; } public void setIncludeParams(String name) { includeParams = name; } public void setAction(String action) { this.action = action; } public void setNamespace(String namespace) { this.namespace = namespace; } public void setMethod(String method) { this.method = method; } public void setScheme(String scheme) { this.scheme = scheme; } public void setValue(String value) { this.value = value; } public void setPortletMode(String portletMode) { this.portletMode = portletMode; } public void setPortletUrlType(String portletUrlType) { this.portletUrlType = portletUrlType; } public void setWindowState(String windowState) { this.windowState = windowState; } public void setAnchor(String anchor) { this.anchor = anchor; } public void setForceAddSchemeHostAndPort(String forceAddSchemeHostAndPort) { this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort; } }
相关文章推荐
- <a href="<s:url action="navDel" ><s:param name="id" value="pid"/></s:url>"> 删除 </a>
- java如何获取jsp页面上传的文件路径 20 前台jsp: <form action="AA.do?method=yktAdd" method="post" > <input type='text'
- meta标签如何实现重定向<meta http-equiv="refresh" content="0; url=">
- javascript学习笔记——如何修改<a href="#">url name</a>
- 使用MvcHandler设计自定义系统权限<上>
- 如何在Html里显示"<"和">"
- Struts2通配符映射/Struts <action name="/*/*" method="{2}" class="com.jxc.action.{1}Action"> <result
- 1.Struts的<action unknown="true">:界面
- 2.Struts的<action unknown="true">:struts-config.xml
- 3.Struts的<action unknown="true">:web.xml
- ssh错误总结1.1----关与struts2中极为恶心的<s:action>标签问题
- struts2配置web的action中的<url-pattern>
- 利用Jsoup解析html,如何得到<img>标签的位置
- 基于Filter<过滤器>登录权限验证设计心得
- WCF常见错误之HTTP could not register URL http://+:80/Temporary_Listen_Addresses/<guid>/ because TCP port 80 is being used by
- Struts2中<jsp:forward page="xxx.action"></jsp:forward>失效
- 关于Action<T>、Func<Tin,Tout> 委托的常见写法
- JSP中 <%@ include file="相对url"%>和path basePath
- (Portal 开发读书笔记)<actionURL><renderURL><resourceURL>
- 使用MvcHandler设计自定义系统权限<下>