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

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

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

    這廝

    observing

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      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 閱讀(368) 評論(1)  編輯  收藏 所屬分類: 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  回復  更多評論
      

    主站蜘蛛池模板: 国产精品亚洲精品日韩已满| 国产成人yy免费视频| 好男人视频社区精品免费| 久久亚洲精品成人无码网站| 久久九九全国免费| 久久夜色精品国产亚洲| 久久精品无码专区免费| 亚洲深深色噜噜狠狠爱网站| 中文字幕免费人成乱码中国| 亚洲精品无码久久久久sm| 国内精品免费久久影院| 亚洲AV综合色区无码一区| 无码少妇精品一区二区免费动态 | 亚洲高清在线视频| 久久精品免费观看| 亚洲精品视频在线观看免费| 我们的2018在线观看免费高清| 亚洲男女一区二区三区| 美女裸身网站免费看免费网站| 亚洲人色大成年网站在线观看| 毛片免费观看的视频在线| 国产精品亚洲va在线观看| 国产精品无码免费视频二三区| 牛牛在线精品免费视频观看| 红杏亚洲影院一区二区三区| 青柠影视在线观看免费| 亚洲美女中文字幕| 日韩精品免费一区二区三区| 日韩免费码中文在线观看| 日本亚洲欧洲免费天堂午夜看片女人员| 先锋影音资源片午夜在线观看视频免费播放 | 蜜桃AV无码免费看永久| 亚洲 欧洲 日韩 综合在线| 在线观看亚洲免费| 国内精品一级毛片免费看| 亚洲乱码中文论理电影| 免费大黄网站在线观看| 亚在线观看免费视频入口| 亚洲欧美日韩自偷自拍| 激情97综合亚洲色婷婷五| 免费做爰猛烈吃奶摸视频在线观看|