如何使用Spring 3.x开发https站点? [英] How to develop https site with Spring 3.x?

查看:120
本文介绍了如何使用Spring 3.x开发https站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是基于Spring的网站开发的新手。

I am a newbie in Spring based web development.

我们的网站是基于Spring的,目前基于http(非常不安全)。
由于该网站尚未生效,我们还通过正常的JSON请求向服务器发送登录名/密码,主要关注JSP,UI设计,SQL查询等。

Our site is Spring based and is currently http based (so quite insecure). Since, the site is not live yet, we are sending login/password also through a normal JSON request to server and have focussed mostly on JSP, UI design, SQL queries etc.

现在,我们希望转向专注于安全性,并转而采用https作为第一步。

Now, we want to shift to focus on security and shift to https as a first step.

我读过一个号码。网页和一些春季书籍似乎没有提供关于如何使用Spring提供https安全性的明确答案。
有人可以帮助我实现上述目标吗?

I have read a no. of web-pages and some spring books but none seems to provide a clear answer on how Spring can be used to provide https security. Can some one please help me in achieving the above?

如果我的问题不明确,请告诉我。我会尽快添加更多详细信息。

Please let me know if my question is not clear. I will try to add more details ASAP.

我们的web.xml如下:

Our web.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
  http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
  http://www.springframework.org/schema/mvc
  http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd    
"
id="WebApp_ID" version="2.5">

<display-name>Spring3MVC</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

<!--> Mapping for serving static web-content <-->
<!--> The resources folder must be in parallel to WEB-INF <-->
<!--> The mvc:resources gives "not bound" exception unless bound to a namespace as above for xmlns:mvc <-->
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/scripts/**" location="/scripts/" />

</web-app>

现在只有一个控制器,spring-servlet.xml如下:

There is only one controller right now for which, spring-servlet.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan
    base-package="console.controllerpkg" />

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

</beans>

提前多多谢谢!

PS如果你可以在春天推荐我一个很好的基于网站/书籍的例子,我将非常感激。我见过的大多数网站/书籍都非常重视理论,但很少有例子。这让我有点困惑。

P.S. If you can recommend me a good example based site/book on spring, it would be much appreciated. Most of the sites/books I have seen lay much emphasis on theory but very little examples. That has left me a little confused.

推荐答案

正如Dave所说,您需要配置容器以提供SSL,然后进行部署你的春季应用程序进入该容器。了解如何配置 Tomcat for SSL。

As Dave says, you need to configure your container to serve SSL, and then deploy your spring app into that container. Learn about configuring Tomcat for SSL.

或者,更灵活地,您可以使用Apache 将您的容器放在前面在那里启用SSL。

Alternately, and more flexibly you can front your container using Apache, and enable SSL there.

这篇关于如何使用Spring 3.x开发https站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆