JavaJSF

JSF, SEO ve PrettyFaces Hakkında

Merhaba Arkadaşlar ,

 

Bu yazımda size web sitelerinin en önemli ihtiyaçlarından SEO yu JSF üzerinde kullanmayı anlatacağım. Bunun için PrettyFaces isimli url-rewrite JSF kütüphanesini kullanacağız.

 

Öncelikle gerekli dosyaları ekleyelim. Kurulum için

  1. <dependency>
        <groupId>org.ocpsoft.rewrite</groupId>
        <artifactId>rewrite-servlet</artifactId>
        <version>2.0.7.Final</version>
    </dependency>
    <dependency>
        <groupId>org.ocpsoft.rewrite</groupId>
        <artifactId>rewrite-config-prettyfaces</artifactId>
        <version>2.0.7.Final</version>
    </dependency>

    pom.xml dosyamıza gerekli kütüphaneleri ekleyelim.  Maven kullanımı hakkında daha ayrıntılı bilgi için Maven Web Site buraya bakabilirsiniz.  

  2. <pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                          http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">
    
            <url-mapping id="watch">
    		<pattern value="/watch" />
    		<view-id value="site/show_video.xhtml" />
    	</url-mapping>
            <url-mapping id="home">
    		<pattern value="/home" />
    		<view-id value="site/index.xhtml" />
    	</url-mapping>
            <url-mapping id="profile">
                <pattern value="/Profile" />
                <view-id value="site/profile.xhtml" /> 
            </url-mapping>
    
    </pretty-config>

WEB-INF/pretty-config.xml isimli bir dosya oluşturarak içine yukarıdaki kod bloğunu ekleyin.

 

Peki Kod bloğu ne iş yapıyor.

<url-mapping id="profile">
</url-mapping>

Yukarıdaki bölüm yönelendirmeniz için isim tanımlamanıza yarıyor. Örneğin ben Profil Sayfası için “profile” tagını belirledim.

  <pattern value="/Profile" />
  <view-id value="site/profile.xhtml" />

Yukarıdaki Kod bloğunda ise pattern ana dizin linkinizden sonra gelecek kısım ;

Örnek Link : localhost/Profile olarak  gelirse bu link : localhost/site/profile.xhtml olarak işlem görecek.

 

 

Muharrem Tığdemir

Author

Muharrem Tığdemir

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.