这是我的代码我所做的我已经完成了将私有端口转发到公共 IP 但在公共 IP 中它不会呈现 geoip.js 但它会在本地地址上正常工作
http://61.12.124.234:8080/zipgrocery/home(my public ip)
它不会呈现 geoip.js 并在本地地址中正常工作。geoip.js 在用户登录时给出城市名称和运行时
basepage.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-responsive.css">
<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/jquery.toastmessage.css"
type="text/css" media="all" />
<link rel="stylesheet" href="css/NewHomePage_style.css">
<!-- sliderman.js -->
<script type="text/javascript" src="js/sliderman.1.3.6.js"></script>
<link rel="stylesheet" type="text/css" href="css/sliderman.css" />
<!-- /sliderman.js -->
<script type="text/javascript" src="//j.maxmind.com/js/geoip.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.toastmessage.js"></script>
<script type="text/javascript" src="js/jquery.tabSlideOut.v1.3.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="js/zipjs.js"></script>
<script type="text/javascript" src="js/jquery.inputhints.min.js"></script>
<script type="text/javascript" src="js/jquery.nivo.slider.pack.js"></script>
<script language="javascript" src="/tweet/jquery.tweet.js"
type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
/* $("#city-dropdown").click(function(){
$("#user-acc-drop").hide();
$("#drop").slideToggle();
});
*/
$("#city-dropdown-text").val(geoip_city())
var text = $("#city-dropdown-text").val();
$("#txtCityName").val(text);
$("#user-acc").click(function(){
$("#drop").hide();
$("#user-acc-drop").slideToggle();
});
$("#pageHolder").click(function(){
closeMenu();
});
$(document).bind('keydown', function(e) {
if (e.which == 27) {
closeMenu();
}
});
$("#city-dropdown-text").click(function() {
var text = $("#city-dropdown-text").val();
$("#txtCityName").val(text);
});
$("#city-dropdown-text").keyup(function(e) {
var text = $("#city-dropdown-text").val();
$("#txtCityName").val(text);
});
$('#city-dropdown-text-autocomplete').live('click', function() {
var text = $("#city-dropdown-text").val();
$("#txtCityName").val(text);
});
documentReady()
});
function removeClass(){
$("#drop li").removeClass("current");
}
function closeMenu(){
$("#drop").hide();
$("#user-acc-drop").hide();
}
</script>
</head>
<body>
<div class="row-fluid mainContain">
<div class="span12 head">
<div class="span3 logoo">
<a href="#" wicket:id="lnkHomeIcon"><img
src="images/zip-grocery-logo.png" /></a>
</div>
<div class="span6 navBar ">
<div class="span1 menu">GET THE APP!</div>
<div class="span1 menu3" wicket:id="lnkRegister">SIGN UP</div>
<div class="span1 menu2" id="" wicket:id="lnkLogin">LOGIN</div>
<div class="span1 menu2" wicket:id="lnkUser"
style="pointer-events: none;">
<span class="link-user" wicket:id="lbUser"></span>
</div>
<span class="user-acc" id="user-acc" wicket:id="lnkuseracc">
<img src="images/imgArrow.png" />
<ul id="user-acc-drop" class="arrow_box2"
style="display: none; position: absolute;">
<li wicket:id="lnkSettings"><a href="">Setting</a></li>
<li wicket:id="lnkLogout"><a href="">Logout</a></li>
</ul>
</span> <span class="span5 text" id="city-dropdown"> <input
type="text" wicket:id="txtzipcode" id="city-dropdown-text"
class="home-search-zip"> <!-- <span wicket:id="currentLoc" class="city-name">HOBOKEN, NJ(7030)</span>
<img src="images/imgArrow.png"/>
<ul id="drop" class="arrow_box">
<li wicket:id="Hobokencity">Hoboken, NJ</li>
<li wicket:id="JerseyCity">Jersey City, NJ</li>
<li wicket:id="MidtownNYC">Midtown, NYC</li>
</ul>-->
</span>
</div>
</div>
<!--
repalce part by pages
-->
<div id="pageHolder">
<wicket:child></wicket:child>
</div>
<div wicket:id="login">
<div wicket:id="loginPanel" />
</div>
<!-- footer start -->
<div class="span12 footer_bar">
<div class="span12 footer_Pad">
<div class="span12 browse_by">Browse By</div>
<div class="span12 city">City</div>
<table>
<tbody>
<tr>
<td><span class="foot-link" wicket:id="lnkHoboken">Hoboken,
NJ</span></td>
<td><span class="foot-link" wicket:id="lnkJersey">Jersey
City, NJ</span></td>
<td><span class="foot-link" wicket:id="lnkMidtown">Midtown,
NYC</span></td>
</tr>
</tbody>
</table>
<hr>
<div class="span12 cuisine">Cuisine / Specialty Store</div>
<table class="cuisineStore">
<tbody>
<tr>
<td>Asian</td>
<td>Italian</td>
<td>Pharmacy</td>
<td>Groceries</td>
<td>Pizzeria</td>
</tr>
<tr>
<td>BBQ</td>
<td>Deli</td>
<td>Liqour Store</td>
<td>Middle Eastern</td>
<td></td>
</tr>
</tbody>
</table>
<hr>
<div class="span12 links_section">
<div class="span2 links_header">
<a href="" wicket:id="lnkAbout">About Us</a>
</div>
<div class="span2 links_header add">
<a href="">Advertise Here</a>
</div>
<div class="span2 links_header getList">
<a href="">Get Listed</a>
</div>
<div class="span2 links_header work-with">
<a href="" wicket:id="lnkCareers">Work With Us</a>
</div>
<div class="span2 links_header faq">
<a href="" wicket:id="lnkFaq">FAQ</a>
</div>
<div class="span2 links_header contac-us">
<a href="" wicket:id="lnkContactUs ">Contact Us</a>
</div>
</div>
<div class="span12 second_row">
<div class="span3 secondrow_containt">
<a href="">All Rights reserved to ZipGrocery.</a>
</div>
<div class="span3 secondrow_containt2">
<a href="">Privacy Policy.</a>
</div>
<div class="span2 secondrow_containt3">
<a href="">Terms and Conditions.</a>
</div>
</div>
</div>
</div>
<!-- footer end -->
</div>
</body>
</html>
basepage.java
package com.zipgrocery.pages;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.visural.wicket.component.dialog.Dialog;
import com.zipgrocery.ZipSession;
import com.zipgrocery.data.Zip;
import com.zipgrocery.panels.LoginPanel;
public class ZBasePage extends WebPage{
/**
*
*/
private static final long serialVersionUID = -4591920443207458425L;
private AjaxFallbackLink lnkLogin;
private Link<String> lnkLogout;
private Link<String> lnkOrders;
private AjaxFallbackLink lnkRegister;
private Link<String> lnkUser;
private Link<String> lnkSettings;
private Link<String> lnkMerchantEdit;
private Link<String> lnkMerchantLogout;
private Link<String> lnkAbout;
private Link<String> currentcity;
private Dialog loginBox;
private LoginPanel loginPanel;
private AjaxFallbackLink lnkHoboken,lnkJersey,lnkMidtown;
private AjaxFallbackLink Hobokencity,JerseyCity,MidtownNYC;
private List<Component> componentList = new ArrayList<Component>();
private String zipcode="07030";
public ZBasePage() {
//navigation for logo
add(new Link<String>("lnkHomeIcon") {
@Override
public void onClick() {
PageParameters params = new PageParameters();
params.set("zipcode", ZipSession.get().getAttribute("currentZip"));
setResponsePage(ZHomePage.class, params);
}
});
/*render all location or zip
List<String> zoneName=Zip.getZoneNames();
for(int i=0;i<zoneName.size();i++){
System.out.println(zoneName.get(i));
}*/
// add search field
final AutoCompleteTextField<String> txtZipcode = new AutoCompleteTextField<String>(
"txtzipcode", new Model<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getZipcode();
}
@Override
public void setObject(String object) {
setZipcode(object);
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected Iterator<String> getChoices(String input) {
return Zip.getUniqueZipsAndZones(input).iterator();
}
};
add(txtZipcode)
;
//navigation links edit by
lnkAbout = new Link<String>("lnkAbout") {
@Override
public void onClick() {
setResponsePage(FaqPage.class);
}
@Override
public boolean isVisible() {
return !ZipSession.get().MerchantisValid();
}
};
lnkAbout.setOutputMarkupPlaceholderTag(true);
add(lnkAbout);
/* final Model<String> lnkuseraccmodel = new Model<String>();
final WebMarkupContainer lnkuseracc=new WebMarkupContainer("lnkuseracc",lnkuseraccmodel);
lnkuseracc.setOutputMarkupId(true);
lnkuseracc.setOutputMarkupPlaceholderTag(true);
add(lnkuseracc);
*/
final WebMarkupContainer lnkuseracc = new WebMarkupContainer("lnkuseracc");
lnkuseracc.setOutputMarkupPlaceholderTag(true);
add(lnkuseracc);
if(ZipSession.get().getCustomer() != null)
lnkuseracc.setVisible(true);
else
lnkuseracc.setVisible(false);
lnkUser = new Link<String>("lnkUser") {
@Override
public void onClick() {
}
};
lnkUser.setOutputMarkupId(true);
add(lnkUser);
//current user
lnkUser.add(new Label("lbUser", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if(lnkuseracc!=null && ZipSession.get().getCustomer() != null)
lnkuseracc.setVisible(true);
return ZipSession.get().getCustomer() == null ? "" : ZipSession.get().getCustomer().getEmail();
}
}).setEscapeModelStrings(false));
lnkUser.setOutputMarkupId(true);
//current city
/*currentcity.add(new Label("currentcity", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return " ";
}
}).setEscapeModelStrings(false));
currentcity.setOutputMarkupId(true);
add(currentcity);*/
//logout link
lnkLogout = new Link<String>("lnkLogout") {
@Override
public void onClick() {
ZipSession.get().invalidate();
setResponsePage(ZHomePage.class);
}
@Override
public boolean isVisible() {
return ZipSession.get().isValid();
}
};
lnkLogout.setOutputMarkupId(true);
lnkLogout.setOutputMarkupPlaceholderTag(true);
lnkuseracc.add(lnkLogout);
lnkSettings = new Link<String>("lnkSettings") {
@Override
public void onClick() {
setResponsePage(CustomerProfilePage.class);
}
@Override
public boolean isVisible() {
return ZipSession.get().isValid();
}
};
lnkSettings.setOutputMarkupId(true);
lnkSettings.setOutputMarkupPlaceholderTag(true);
lnkuseracc.add(lnkSettings);
/*login code start here */
lnkLogin = new AjaxFallbackLink("lnkLogin") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
ajaxRequestTarget.add(loginPanel);
ajaxRequestTarget.add(loginBox);
loginBox.open(ajaxRequestTarget);
ajaxRequestTarget.appendJavaScript("documentReady()");
}
@Override
public boolean isVisible() {
return !ZipSession.get().isValid();
}
};
add(lnkLogin);
lnkRegister = new AjaxFallbackLink<String>("lnkRegister") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
setResponsePage(CustomerProfilePage.class);
}
@Override
public boolean isVisible() {
return !ZipSession.get().isValid();
}
};
add(lnkRegister);
//login dialog
loginBox = new Dialog("login");
loginPanel = new LoginPanel("loginPanel", loginBox, getRefreshables());
loginPanel.setOutputMarkupId(true);
loginBox.add(loginPanel);
add(loginBox);
/*login code end here*/
/*footer menu code*/
lnkHoboken = new AjaxFallbackLink("lnkHoboken") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
mearchentListByCity("Hoboken");
}
};
add(lnkHoboken);
lnkJersey = new AjaxFallbackLink("lnkJersey") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
mearchentListByCity("Jersey City");
}
};
add(lnkJersey);
lnkMidtown = new AjaxFallbackLink("lnkMidtown") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
mearchentListByCity("Midtown NYC");
}
};
add(lnkMidtown);
//contact us link
add(new Link<String>("lnkContactUs") {
@Override
public void onClick() {
setResponsePage(ContactUsPage.class);
}
});
//end of contact us
//faq link
add(new Link<String>("lnkFaq") {
@Override
public void onClick() {
setResponsePage(FaqPage.class);
}
});
//end of faq
//career link
add(new Link<String>("lnkCareers") {
@Override
public void onClick() {
setResponsePage(CareerPage.class);
}
});
//end of career
/*code for city selection*/
String defaultCity = "Hoboken";
if(ZipSession.get().getZipcode()!=null && ZipSession.get().getZipcode().length()>0){
if(ZipSession.get().getZipcode().equals("07030")){
defaultCity ="HOBOKEN";
}else{
defaultCity = ZipSession.get().getZipcode();
}
}
/* final Model<String> model = new Model<String>(defaultCity);
final Label currentCityLbl=new Label("currentLoc",model);
currentCityLbl.setOutputMarkupId(true);
currentCityLbl.setOutputMarkupPlaceholderTag(true);
add(currentCityLbl);
Hobokencity = new AjaxFallbackLink("Hobokencity") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
//mearchentListByCity("Hoboken");
ZipSession.get().setZipcode("Hoboken");
model.setObject("Hoboken");
currentCityLbl.setDefaultModel(model);
ajaxRequestTarget.addComponent(currentCityLbl);
}
};
JerseyCity = new AjaxFallbackLink("JerseyCity") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
//mearchentListByCity("Jersey City");
ZipSession.get().setZipcode("Jersey City");
model.setObject("Jersey City");
currentCityLbl.setDefaultModel(model);
ajaxRequestTarget.addComponent(currentCityLbl);
}
};
MidtownNYC = new AjaxFallbackLink("MidtownNYC") {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
//mearchentListByCity("Midtown NYC");
ZipSession.get().setZipcode("Midtown NYC");
model.setObject("Midtown NYC");
currentCityLbl.setDefaultModel(model);
ajaxRequestTarget.addComponent(currentCityLbl);
}
};
add(Hobokencity);
add(JerseyCity);
add(MidtownNYC);*/
}
protected void mearchentListByCity(String city){
PageParameters pageParameters = new PageParameters();
try{
pageParameters.add("citySearch",true);
pageParameters.add("zipcode",city);
}catch(Exception e){
e.printStackTrace();
}
setResponsePage(HomePage.class, pageParameters);
}
protected final List<Component> getRefreshables() {
for (Component c : componentList) {
if (c != null) {
c.setOutputMarkupId(true);
c.setOutputMarkupPlaceholderTag(true);
}
}
componentList.add(lnkLogout);
componentList.add(lnkSettings);
componentList.add(lnkLogin);
componentList.add(lnkRegister);
/*componentList.add(lnkOrders);*/
componentList.add(lnkUser);
return componentList;
}
public String getZipcode() {
return zipcode;
}
public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}
}
帮我解决这个问题.......................