停止在Apache Tiles和Spring MVC中缓存单个磁贴

时间:2015-04-20 10:23:47

标签: java spring-mvc tomcat spring-security apache-tiles

使用Spring MVC和Apache Tiles时,我遇到了缓存tile的问题。

我有一个管理页面,有很多用户。登录工作完美,用户生成的内容映射到正确的用户,但是当用户登录时,他们会互相获取内容! (例如,顶部中的用户名在所有用户之间切换,因此您可以看到其他用户的用户名。)

用户使用Spring Security登录。

我试图找出如何转换tile的缓存,因为我认为它可能与Apache Tiles有关,而不是Spring MVC。

非常欢迎所有解决方案的建议。

编辑:

菜单图块:

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="isAuthenticated()">
    <ul class="nav navbar-nav">
        <li class="${param.currentView eq 'index' ? 'active' : ''}"><a href="/apps/blogs/">My articles</a></li>
        <li class="${param.currentView eq 'article' ? 'active' : ''}"><a href="/apps/blogs/new">New article</a></li>
        <sec:authorize access="hasRole('ROLE_ADMIN')">
            <li class="dropdown" class="${param.currentView eq 'admin' ? 'active' : ''}">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><a href="/apps/blogs/admin/">Users</a></li>
                </ul>
            </li>

        </sec:authorize>
    </ul>
    <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><sec:authentication
                    property="principal.firstName"/>&nbsp;<sec:authentication
                    property="principal.lastName"/><b class="caret"></b></a>
            <ul class="dropdown-menu">
                <li><a href="j_spring_security_logout">Logout</a></li>
                <li class="divider"></li>
                <li><a href="/apps/blogs/changePassword">Change password</a></li>
            </ul>
        </li>

    </ul>
</sec:authorize>

BlogsController:

@Controller
@RequestMapping(value = "/", produces = "application/json")
@Secured("ROLE_USER")
public class BlogsController {

    @RequestMapping(value = "/", produces = "text/html")
    public String index(Model model, Authentication auth, @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "showDeletedOnly", defaultValue = "false") boolean showDeletedOnly, @RequestParam(value = "sectionId", defaultValue = "-1") int sectionId, @RequestParam(value = "username", defaultValue = "") String username) {

        double resultsPrPage = 10.0; // Double type is used, to calculate the last page using Math.ceil.

        BlogUser userDetails = (BlogUser) auth.getPrincipal();

    // CODE RETRIEVING THE BLOG ENTRIES....

        return "index";
    }
}

瓷砖配置:

<bean id="tilesViewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
              value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/views/blogs/shared/views.xml</value>
        </list>
    </property>
</bean>

0 个答案:

没有答案