<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 閱讀(360) 評論(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  回復  更多評論
      

    主站蜘蛛池模板: 日韩精品无码一区二区三区免费| 青草青草视频2免费观看| 99在线观看视频免费| 久久久久亚洲精品无码网址| 久青草国产免费观看| 亚洲精品黄色视频在线观看免费资源| 国产精品亚洲专区在线播放| 免费国产综合视频在线看| 美女扒开尿口给男人爽免费视频| 四虎国产精品免费久久影院| 四虎影视永久在线精品免费| 在线观看午夜亚洲一区| 好紧我太爽了视频免费国产| 久久亚洲精品无码aⅴ大香| 99re热精品视频国产免费| 亚洲av日韩av无码| 免免费国产AAAAA片| 亚洲中文无码永久免费| 国产一级淫片免费播放| 一个人看的免费视频www在线高清动漫| 亚洲人成网亚洲欧洲无码久久| 另类免费视频一区二区在线观看 | 亚洲伊人久久大香线蕉结合| 夭天干天天做天天免费看| 日韩在线一区二区三区免费视频 | 亚洲高清无码综合性爱视频| 一级毛片免费在线播放| 亚洲AV无码久久精品蜜桃| 亚洲精品视频免费在线观看| 风间由美在线亚洲一区| 亚洲线精品一区二区三区 | 四虎必出精品亚洲高清| 亚洲国产精品一区二区九九| 无码A级毛片免费视频内谢| 亚洲色丰满少妇高潮18p| 久久久久亚洲精品男人的天堂| h视频在线观看免费完整版| 亚洲av永久无码精品网址| 亚洲AV无码一区二区二三区入口| 亚洲天堂免费在线| 久99久无码精品视频免费播放|