I attempted to create a struts2 component using jsp,and I used UTF-8 header in both jsp pages,but in final result I see that those symbols came corrupted. If I change UTF-8 into GBK,it will be ok,I want to kown the reason why 'UTF-8' doesn't work, thanks!!! Struts version 2.1.8
<%# page contentType="text/html; charset=UTF-8" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%# taglib uri="/struts-tags" prefix="s"%>
componentTag.jsp
<s:component template="mytemplate.jsp">
<s:param name="list" value="{'java程序设计','Ajax完全学习手册','Struts2学习手册'">
</s:param>
</s:component>
mytemplate.jsp (/WebRoot/template/xhtml)
<div style="background-color:#eeeeee;" >
<b>JSP自定义模板</b><br/>
图书列表:<s:select list="parameters.list"></s:select>
</div>
set the JVM boot parameter of -Dfile.encoding=utf-8
MyEclipse (MyEclipse->preferences->servers->chose your version and then chose JDK to set the boot parameters)
you may try add these to your struts.xml
struts.locale=zh_CN
struts.i18n.encoding=UTF-8
if not specified in struts.xml or struts.properties
struts2 will pick the encoding of your platform(of widows it is gbk by default)
很高兴遇见你
Related
I did a Struts2 tutorial and everything works, however I am left with a Warning:
The tag handler class for <s:property> (org.apache.struts2.views.jsp.PropertyTag) was not found on the Java Build Path HelloWorld.jsp
I can't seem to find which library is missing especially since it runs fine.
Move <%# taglib prefix="s" uri="/struts-tags"%> to the very first line of your jsp - it removes the warning
I ran into this problem:
Mine was: <%# taglib prefix="s" uri="/struts-tags"% >
I had a space after the last %
When I deleted the space it solved all my warnings.
org.apache.struts2.views.jsp.PropertyTag is contained in Struts 2 Core 2.x.x.x API.
In Jsp file you have to import this tag-lib by adding following import code in top of your jsp.
<%# taglib prefix="s" uri="/struts-tags"%>
I had the same problem. After adding struts2-core-2.1.8.jar, the warning was gone and my project executed successfully.
Add these two lines under the struts tag:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
I have the following problem, We have web content manager (WCM) running at remote host,
which is responsible for generating header and footer HTML files.
i.e. header.html, footer.html.
The HTML files are not properly formatted syntax wise,
WCM generated files have
Space character ( ) 🡢 it is not allowed in XHTML.
Non Closing break line (<br>) tags 🡢 it is invalid in XHTML.
So the WCM generated HTML pages might not be valid XHTML pages.
We are implementing some of our applications in JSF,
where we need to include the WCM generated header and footer files.
Can we include the non-formatted HTML files into our XHTML files?
commonTemplate.xhtml
<html>
<head>
..........;
</head>
<body>
<ui:include src="remote_host/header.html" />
<ui:insert name="commonBodyContent" />
<ui:include src="remote_host/footer.html" />
</body>
</html>
I guess it is related to this question: Include non-Facelet content in a Facelet template
I do not recommend to mix XHTML with HTML, but most probably the browsers will not have any issues with the mentioned characters, hence you might try to directly render the file contenty, e.g. by
<h:outputText value="#{yourBean.headerCode}" escape="false" />
Whereas YourBean.getHeaderCode() would readout the header file's content and return it as String. YourBean should be ApplicationScoped.
Faster and better would be to get the WCM generating valid XHTML.
I am using struts2-jquery plugin & using dialog(remote) so i have specified remoteurl before dialog code as shown below:
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<sj:head jqueryui="true"/>
</head>
<body>
<s:url var="remoteurl" action="myremoteaction"/>
<sj:dialog id="mydialog3" href="%{remoteurl}" title="Remote Dialog open on Click" autoOpen="false"/>
<sj:a openDialog="mydialog3">Open Dialog</sj:a>
</body>
</html>
When i click on hyperlink instead of opening dialog directly first i want to change its remoteurl & then want to open it
Can somebody tell me how should i do this?
Thanks in advance.
You can try this. I've not tested it but i believe it will give you a clue on how to solve the problem. Change the value of the href attribute before opening the dialog using something like this:
$("#mydialog3").dialog( "option" , "href", your_new_url );
$("#mydialog3").dialog('open')
You can also visit the Struts2 jquery showcase page for more clarification.
I have ASP.NET MVC 3 application having resource files in english and french.
A text 'Sélectionner la pharmacie' is stored in a french resource file.
When the value is read from resource files with razor syntax, it shows
'S#233;lectionner la pharmacie' instead of 'Sélectionner la pharmacie'.
e.g.
#MyResources.Strings_Resources.lbl_SelectPharmacy
Is there a way I can make it show the french accent characters ?
I suspect that your text is already encoded and razor is trying to encode it again (it encodes all outputs)
Try with
#Html.Raw(MyResources.Strings_Resources.lbl_SelectPharmacy)
First check your master page, you have set UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<system.web>
<globalization enableclientbasedculture="true" uiculture="auto" culture="auto">
<!-- Use above or below <globalization> line, based on your site -->
<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>
</system.web>
If you have set this already then try below setup:-
<asp:Label Text="<%$ Resources:Strings, MyGlobalResource %>" runat="server" />
<asp:Label Text="<%$ Resources:MyLocalResource %>" runat="server" />
<%= HttpContext.Current.GetLocalResourceString("~/YOURASPXPAGE", "MyLocalResource", CultureInfo.CurrentUICulture) %>
Refer this URL for more info:-
ASP.NET MVC 3 Internationalization
ASP.NET MVC - Localization Helpers
I was having problem showing French characters in textarea through JQuery/Javascript (asp.net mvc).
myArry.push("\r\n" + "SÉRIE CERVICALE");
$('#myTextArea').val(myArry);
Result 🙁: SÉRIE CERVICALE
Adding this line in Web.config worked for me.
<system.web>
<globalization fileEncoding="utf-8" requestEncoding="utf-8"responseEncoding="utf-8"/>
</system.web>
Result 🙂: SÉRIE CERVICALE
I am taking a prototype of a web page and implementing it. The prototype makes heavy use of DOJO for some fancy UI elements. The application is built using Struts 2.1.8.1 with the DOJO plugin enabled. I am able to use the dojo specific tags within struts but I can't get the any of the dijit widgets to work.
<%# page contentType="text/html; charset=UTF-8" %>
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sx" uri="/struts-dojo-tags" %>
<html xmlns="\"http://www.w3.org/1999/xhtml\"" xml:lang="\"en\"" lang="\"en\"">
<head>
<sx:head parseContent="true" />
<script type="text/javascript">
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.TimeTextBox");
dojo.require("dijit.form.Slider");
dojo.require("dijit.Menu");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.blue");
dojo.require("dojox.charting.themes.PlotKit.orange");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.SplitContainer");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.Tooltip");
</script>
The error I'm getting is:
GET http://localhost:9080/quickstart/struts/dijit/Dialog.js
GET http://localhost:9080/quickstart/struts/dijit/Dialog.js
404 Not Found
struts_dojo.js (line 769)
GET http://localhost:9080/quickstart/struts/dijit.js
GET http://localhost:9080/quickstart/struts/dijit.js
404 Not Found
struts_dojo.js (line 769)
ParamsHeadersPostPutResponseCacheHTML
Error 404: Error reported: 404
GET http://localhost:9080/quickstart/struts/dojo/__package__.js
GET http://localhost:9080/quickstart/struts/dojo/__package__.js
404 Not Found
struts_dojo.js (line 769)
ParamsHeadersPostPutResponseCacheHTML
Error 404: Error reported: 404
Could not load 'dijit.Dialog'; last tried '__package__.js'
[Break on this error] throw _13||Error(_12);
Do I need to make a special build of Dojo to get access to these dijit widgets?
The answer is because struts, as late as Struts 2.1.8.1 which is the most recent version as I am writing this, includes DOJO 0.4. Dijit seems to have been introduced sometime after Dojo 1.0. (Current version is 1.4).
The widget library to use with Struts is Dojo.widget which gets loaded by default with struts.