0

我正在两台具有几乎相同规格的不同机器上开发(Win 7、eclipse juno、tomcat 7),源代码从 github 签出。

但是在我的笔记本电脑上,我的 url 行为与我的工作站上的不同。进入

http://localhost:8080/jeiwomisa/auth/login.xhtml 

适用于我的笔记本电脑,但不适用于我的工作站。

在我的工作站上,我必须使用:

http://localhost:8080/jeiwomisa/faces/auth/login.xhtml

不同之处在于“/faces/”部分。这对所有链接都是一样的。我不明白,因为我认为我在两台机器上都有相同的配置。

我不确定这个问题究竟需要哪种配置,所以我只发布了我的 web.xml:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


<!-- -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/app/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<!-- pretty faces -->

<filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>


<context-param>
    <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name>
    <param-value>de.sveri.jeiwomisa.managed</param-value>
</context-param>

<!-- Project Stage Level -->
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<!-- JSF Servlet is defined to container -->
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

这是我定义 login.xhtml 的 security-app-context.xml:

<http use-expressions="true" auto-config="true">
    <intercept-url pattern="/test/**" access="permitAll" />
    <intercept-url pattern="/tasks/**" access="isAuthenticated()" />

    <!-- <intercept-url pattern="/**" access="denyAll" /> -->
    <form-login login-page="/auth/login.xhtml" />   
</http>

<context:annotation-config />
<b:bean id="userRepositoryImpl" class="de.sveri.jeiwomisa.model.UserRepositoryImpl"
    autowire="byType">
</b:bean>

<b:bean id="passwordEncoder"
    class="org.springframework.security.crypto.password.StandardPasswordEncoder">
</b:bean>


<authentication-manager>
    <authentication-provider user-service-ref="userRepositoryImpl">
            <password-encoder hash="md5" />
    </authentication-provider>
</authentication-manager>

如果需要,可以在以下位置找到完整代码:github 代码

最好的问候, 斯文

4

2 回答 2

0

you should add servlet mapping for both applications. try to add following code to youe web.xml file.

    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
于 2012-08-27T07:18:07.323 回答
0

奇怪的。尝试清除浏览器缓存?您的配置肯定是正确的。

于 2012-08-28T13:59:21.807 回答