<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    這廝

    observing

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      48 Posts :: 3 Stories :: 3 Comments :: 0 Trackbacks
    Using Spring Security in your Java web application

    Sample applications were developed and deployed in the environment described below:

    1. JDK 1.6.11
    2. JBoss Application Server 5.1.0
    3. Spring Framework 3.0.3
    4. Spring Security 3.0.3
    5. Eclipse IDE 3.5 (Galileo)
    6. JavaServer Faces 1.2 (JSF) – No separate implementations were used other than what's found with JBoss 5.1.0
    loading config - web.xml file:
    <?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"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="WebApp_ID" version="2.5">
        <display-name>JSFSpringNoSecurityWebApp</display-name>
    
        <!-- Spring configuration file location -->
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/applicationContext-business.xml
            </param-value>
        </context-param>
    
        <!-- To start/stop Spring framework automatically. -->
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>
    
        <welcome-file-list>
            <welcome-file>index.html</welcome-file>
            <welcome-file>index.htm</welcome-file>
            <welcome-file>index.jsp</welcome-file>
            <welcome-file>default.html</welcome-file>
            <welcome-file>default.htm</welcome-file>
            <welcome-file>default.jsp</welcome-file>
        </welcome-file-list>
    
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
    </web-app>
     Spring config - applicationContext-business.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    
        <bean id="calculatorBean" class="org.swview.springsecuritytestapp.logic.CalculatorIpml">
        </bean>
    </beans>
    JSF config - 
    faces-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    
    <faces-config
        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-facesconfig_1_2.xsd"
        version="1.2">
    
        <application>
            <el-resolver>
              org.springframework.web.jsf.el.SpringBeanFacesELResolver
            </el-resolver>
        </application>
        
        <managed-bean>
            <managed-bean-name>calculatorController</managed-bean-name>
            <managed-bean-class>
              org.swview.springsecuritytestapp.jsf.CalculatorController
            </managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>calculator</property-name>
                <value>#{calculatorBean}</value>
            </managed-property>
        </managed-bean>
    </faces-config>
    

    page file - 
    calculator.jsp file
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Calculator</title>
    </head>
    <body>
    <f:view>
    <h:form>
        <h:panelGrid border="1" columns="3">
            <h:outputLabel value="Number 1:"></h:outputLabel>
            <h:inputText value="#{calculatorController.number1}" id="number1Field">
                <f:convertNumber />
            </h:inputText>
            <h:message for="number1Field"></h:message>
            <h:outputText value="Number 2:"></h:outputText>
            <h:inputText value="#{calculatorController.number2}" id="number2Field">
                <f:convertNumber />
            </h:inputText>
            <h:message for="number2Field"></h:message>
            <h:outputLabel value="Sum:"></h:outputLabel>
            <h:outputLabel value="#{calculatorController.results}"></h:outputLabel>
        </h:panelGrid>
        <h:commandButton value="Add Again"
            action="#{calculatorController.add}"></h:commandButton>
    </h:form>
    </f:view>
    </body>
    </html>

    Controller:

    package org.swview.springsecuritytestapp.jsf;
    
    import org.swview.springsecuritytestapp.logic.Calculator;
    
    public class CalculatorController {
        private double number1;
        private double number2;
        private double results;
        
        private Calculator calculator;
        
        public void setCalculator(Calculator calculator) {
            this.calculator = calculator;
        }
    
        public double getNumber1() {
            return number1;
        }
        public void setNumber1(double number1) {
            this.number1 = number1;
        }
        public double getNumber2() {
            return number2;
        }
        public void setNumber2(double number2) {
            this.number2 = number2;
        }
        public double getResults() {
            return results;
        }
        public void setResults(double results) {
            this.results = results;
        }
    
        public String add() {
            results = calculator.add(number1, number2);
            return "success";
        }    
    }
    
    Spring bean implementation
    package org.swview.springsecuritytestapp.logic;
    
    public class CalculatorIpml implements Calculator {
        
        public double add(double a, double b) {
            return a + b;
        }
        
        public double subtract(double a, double b) {
            return a - b;
        }
    }

    ---testing.. to be continue


    posted on 2011-12-22 22:53 cnbarry 閱讀(359) 評(píng)論(1)  編輯  收藏 所屬分類(lèi): Java

    Feedback

    # re: 【hello world】Using Spring Security in JWA (1) - no security case 2011-12-22 22:55 cnbarry
    Note:
    From - http://www.swview.org/blog/using-spring-security-your-java-web-application  回復(fù)  更多評(píng)論
      


    只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲综合无码精品一区二区三区| 亚洲国产精品成人精品软件| 久久久国产精品福利免费| 久久狠狠高潮亚洲精品| 国外成人免费高清激情视频| 麻豆va在线精品免费播放| 亚洲VA中文字幕不卡无码| 成人奭片免费观看| 一级特黄录像视频免费| 久久久亚洲欧洲日产国码是AV| 拔擦拔擦8x华人免费久久| 少妇太爽了在线观看免费视频| 亚洲日韩国产二区无码| 亚洲国产精品久久久天堂 | 成年女性特黄午夜视频免费看| 国产成人va亚洲电影| 内射少妇36P亚洲区| 亚洲人成色7777在线观看不卡| 一级特黄aa毛片免费观看| 杨幂最新免费特级毛片| 亚洲国产成人久久| 亚洲无av在线中文字幕| 日韩一品在线播放视频一品免费| 亚洲精品免费视频| 日韩在线观看免费| 国产亚洲精品影视在线| 久久亚洲精品无码AV红樱桃| 亚洲精品色婷婷在线影院| 日韩免费视频播播| 亚洲免费在线观看视频| 中文字幕在线视频免费观看| 亚洲AV永久无码精品网站在线观看| 亚洲好看的理论片电影| 亚洲一区精品伊人久久伊人| 午夜免费不卡毛片完整版| 最近免费最新高清中文字幕韩国| 国产国产人免费人成成免视频| 亚洲精品动漫免费二区| 亚洲大香伊人蕉在人依线| 久久亚洲精品中文字幕三区| 亚洲福利在线播放|