javaweb的配置文件在哪?

javaweb的配置文件在哪?,第1张

配置文件的编译位置一般都是在前项目的classpath下,

所以经常把喜欢把配置文件放在src下,

当然也有人提出与src同级的resources用来专门放置配置文件。

你直接写个过滤类就可以了(使用 filter  的3个方法  你懂得)

package com.enation.eopimport java.io.BufferedReaderimport java.io.IOExceptionimport java.io.InputStreamimport java.io.InputStreamReaderimport java.io.PrintWriterimport java.util.Collectionimport java.util.Dateimport java.util.Listimport java.util.Localeimport javax.servlet.Filterimport javax.servlet.FilterChainimport javax.servlet.FilterConfigimport javax.servlet.ServletExceptionimport javax.servlet.ServletOutputStreamimport javax.servlet.ServletRequestimport javax.servlet.ServletResponseimport javax.servlet.http.Cookieimport javax.servlet.http.HttpServletRequestimport javax.servlet.http.HttpServletResponseimport com.enation.eop.processor.back.BackendProcessorimport com.enation.eop.processor.core.freemarker.FreeMarkerPaserimport com.enation.eop.processor.facade.FacadeProcessorimport com.enation.eop.processor.facade.InstallProcessorimport com.enation.eop.processor.facade.ResourceProcessorimport com.enation.eop.resource.IAppManagerimport com.enation.eop.resource.model.EopAppimport com.enation.eop.sdk.context.EopContextimport com.enation.eop.sdk.context.EopContextIniterimport com.enation.eop.sdk.context.EopSettingimport com.enation.framework.context.spring.SpringContextHolderimport com.enation.framework.context.webcontext.ThreadContextHolderpublic class DispatcherDemoFilter implements Filter {    public void init(FilterConfig config) {

}

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

//        HttpServletRequest  req= ServletActionContext.getRequest()//        String  flag= req.getHeader("X-Requested-With")//            HttpServletResponse   response  = ServletActionContext.getResponse()

String ip = ((HttpServletRequest) request).getHeader("x-forwarded-for")       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){

ip = ((HttpServletRequest) request).getHeader("Proxy-Client-IP")

}        if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){

ip = ((HttpServletRequest) request).getHeader("WL-Proxy-Client-IP")

}        if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){

ip = request.getRemoteAddr()

}

String authtoken = request.getParameter("auth-token")

System.out.println(authtoken)

StringBuffer sb = new StringBuffer()

InputStream is = request.getInputStream()

InputStreamReader isr = new InputStreamReader(is)

BufferedReader br = new BufferedReader(isr)

String s = ""

while((s=br.readLine())!=null){

sb.append(s)

}

System.out.println(sb)

String str =sb.toString()

System.out.println(ip+"时间"+new Date().getTime())       //response.setCharacterEncoding("utf-8")

response.setContentType("application/xml")

String write = "<cart><items><item feed-id=\"449573\" offer-id=\"15\" price=\"825\" count=\"1\" delivery=\"true\"/>" +

"</items><delivery-options><delivery service-name=\"Курьер\" type=\"DELIVERY\" price=\"1490.00\">" +

"<dates from-date=\"24-10-2016\" to-date=\"26-10-2016\"/></delivery>" +

"</delivery-options><payment-methods>" +

"<payment-method>CASH_ON_DELIVERY</payment-method></payment-methods></cart>"

System.out.println(write)

response.getWriter().write(write)

}    public void destroy() {

}

private static boolean isExinclude(String uri) {

String[] exts = new String[] { "jpg", "gif", "js", "png", "css", "doc", "xls", "swf","ico" }

for (String ext : exts) {            if (uri.toUpperCase().endsWith(ext.toUpperCase())) {                return true

}

}        return false

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11596282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存