java - PrettyFaces does not work with Struts 2 -
i want make urls nicer seo.
i configured filter , works following e.g.:
<url-mapping> <pattern value="/index" /> <view-id value="/index.html" /> </url-mapping>
but when set view-id struts url not work.
e.g.:
<url-mapping> <pattern value="/index" /> <view-id value="/application/punchit.do" /> </url-mapping>
it can not find (or can not execute) struts actions.
is there solution configure prettyfaces struts 2 framework?
i'm using pretty-faces 3.3.3.
here config of pretty-config.xml:
<?xml version="1.0" encoding="utf-8"?> <pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://ocpsoft.org/prettyfaces/ http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd"> <!-- doesn't work --> <url-mapping> <pattern value="/index.html" /> <view-id value="/application/punchit.do" /> </url-mapping> <!-- works --> <url-mapping> <pattern value="/error" /> <view-id value="/error.html" /> </url-mapping> </pretty-config>
here web.xml:
<?xml version="1.0" encoding="utf-8"?> <web-app id="struts_blank" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>struts blank</display-name> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <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> </web-app>
you have make sure prettyfilter located before struts2 filter , struts2 filter configured process forward dispatcher types. try this:
<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> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> <dispatcher>forward</dispatcher> <dispatcher>request</dispatcher> </filter-mapping>
for detailed explanation, see question #2 here:
http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-us/html/faq.html
Comments
Post a Comment