看一下:server.xml的配置,https配置中加上:scheme="https"指定端口的访问协议是https,如果tomcat版本较老,可以在:web.xml配置指定的哪些网页需要https访问:<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>/admin_index.jsp</url-pattern>
<url-pattern>/login.jsp</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>/admin_index.jsp</url-pattern>
<url-pattern>/login.jsp</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
最笨的办法:在web.xml中增加过滤器:
<!-- 设置过滤器 统计文件下载次数 -->
<filter>
<filter-name>fileDownNum</filter-name>
<filter-class>org.xxx.filter.FileYouClass</filter-class>
</filter>
<filter-mapping>
<filter-name>fileDownNum</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 在:.FileYouClass中,从request中获取访问的协议是http还是https,然后返回给用户页面就好了