要点: ユーザーがログインしたり、POST アクションを実行したりしない限り、アプリにセッションを作成させないでください。request.getSession()
またはに電話しないでくださいrequest.getSession(true)
。ログインしていないユーザーのセッション スコープ Bean を作成または管理しないでください。使用しているフレームワークが不要にセッションを作成しないことを確認してください。
アプリケーションの設計方法や、使用されている (MVC) フレームワークの制限やバグが原因でこれが本当に不可能な場合は、Googlebot リクエストを JSESSIONID 識別子のない URL にリダイレクトすることをお勧めします。これには、 Tuckey の URL 書き換えフィルターを使用できます(これは、たとえば、Apache HTTPD の既知の .xml の Java バリアントですmod_rewrite
)。これは、構成例ページからの関連性の抜粋です。
googlebot からのリクエストの jsessionid を非表示にします。
<outbound-rule>
<name>Strip URL Session ID's</name>
<note>
Strip ;jsession=XXX from urls passed through response.encodeURL().
The characters ? and # are the only things we can use to find out where the jsessionid ends.
The expression in 'from' below contains three capture groups, the last two being optional.
1, everything before ;jesessionid
2, everything after ;jesessionid=XXX starting with a ? (to get the query string) up to #
3, everything ;jesessionid=XXX and optionally ?XXX starting with a # (to get the target)
eg,
from index.jsp;jsessionid=sss?qqq to index.jsp?qqq
from index.jsp;jsessionid=sss?qqq#ttt to index.jsp?qqq#ttt
from index.jsp;jsessionid=asdasdasdsadsadasd#dfds - index.jsp#dfds
from u.jsp;jsessionid=wert.hg - u.jsp
from /;jsessionid=tyu - /
</note>
<condition name="user-agent">googlebot</condition>
<from>^(.*?)(?:\;jsessionid=[^\?#]*)?(\?[^#]*)?(#.*)?$</from>
<to>$1$2$3</to>
</outbound-rule>