HTTPS无法在Netbeans中运行

时间:2015-09-10 05:34:42

标签: java tomcat netbeans https ssl-certificate

我正在Netbeans 7.4创建一个Web应用程序,我使用Apache Tomcat 7.0.41.0作为Web服务器。当我创建我的应用的war文件时,部署在Tomcat Netbeans之外的Netbeans并在https://localhost:8443/MIS中运行应用并且应用有效。但是,当我从Netbeans运行应用时,https会自动重定向到This webpage is not available,浏览器会显示web.xml。我使用Java keytool为我的应用程序创建了证书。

我的 <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>readCert</servlet-name> <servlet-class>readCert</servlet-class> </servlet> <servlet-mapping> <servlet-name>readCert</servlet-name> <url-pattern>/readCert</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <security-constraint> <web-resource-collection> <web-resource-name>This app requires authentication</web-resource-name> <url-pattern>/</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>tomcat</role-name> </auth-constraint> <user-data-constraint> <!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE --> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>CLIENT-CERT</auth-method> </login-config> </web-app> 如下所示:

server.xml

我的 <Connector protocol="org.apache.coyote.http11.Http11Protocol" port="8443" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="D:\misCert.crt" keystorePass="123456" clientAuth="false" sslProtocol="TLS"/> 如下所示:

//in Activity
public static final String EXTRA_STARTED_FROM_MY_SERVICE = "com.example.extra_started_from_sevice";

private boolean wasActivityStartedFromService() {
    Intent startingIntent = getIntent();
    //assuming you will use Intent#putExtra in your service when starting activity
    return startingIntent.getBooleanExtra(EXTRA_STARTED_FROM_MY_SERVICE, false);
}

//...

//in Service

    //...    
    Intent startingIntent = new Intent(this, MainActivity.class);
    startingIntent.putExtra(MainActivity.EXTRA_STARTED_FROM_MY_SERVICE, true);
    startActivity(startingIntent);

我该如何解决这个问题?

0 个答案:

没有答案